I do not think there is a trim function but there is a ^substitute function that you can use to replace the spaces. You could make a function or outputmacro and rename it to ^trim or to ^removespaces like:
Place this at the top of your topic file:
^substitute(character ^text ” ” “” )
Then test with this pattern:
u: (remove spaces in _* ) ^keep() ^repeat() ^removespaces(‘_0)
HARRY: Welcome to ChatScript.
alaric: > remove spaces in a b c