I consider myself pretty good with Regular Expressions, but this one is appearing to be surprisingly tricky: I want to trim all whitespace, except the space character:
' '
[\s-[ ]]
' '
project team manage key
Try using this regular expression:
[^\S ]+
It's a bit confusing to read because of the double negative. The regular expression [\S ]
matches the characters you want to keep, i.e. either a space or anything that isn't a whitespace. The negated character class [^\S ]
therefore must match all the characters you want to remove.