Regex To Remove Unnecessary Spaces In A String

Category: Strings

A regular expression to match unnecessary whitespaces in a string (excluding spaces between words). Can be useful in removing all unexpected white spaces at the beginning or end of strings.



  • RegexPattern<SPACE>
  • <SPACE>RegexPattern


  • Regex<SPACE>Pattern

See Also:

Rate This Regex
User Review
0 (0 votes)

Expression Flags

Flags Description
i Ignore case sensitive.
g Allows global search.
m Allows multiline search.