Remove all spaces

Am I missing something obvious? I want to remove all the spaces from an input. What I have now is a split on spaces and then a repeat to add each element to a variable. Seems kludgy.

A quick regex in Shortcuts perhaps?

3 Likes

Huh. I’ll have to look up what (m?) means, haven’t seen that before, but works a treat, thanks!

That sets the flag for multiline, so that ^ and $ match the start and end of a line instead of the start and end of the whole string. In this case it isn’t needed :wink:

I use regex101.com for all regex stuff and note that Shortcuts uses the ICU flavor of regular expressions

1 Like

\s worked for what I needed, no multi-line input.

I usually split on spaces, then join with an empty string (""). Slightly less elegant than a regex, but easier to remember!

With the growing complexity of shortcuts and the terrible UI for managing long ones, I have a lot of appreciation for reducing the number of actions in the shortcut.

1 Like