Remove multiple leading and trailing space

You can create an action around
$trim(x,c)

From the documentation:

or you try one of the other FAQ entries: