Remove all spaces

#1

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.

0 Likes

#2

A quick regex in Shortcuts perhaps?

3 Likes

#3

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

0 Likes

#4

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

#5

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

0 Likes

#6

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

0 Likes

#7

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