A regular expression to match all whitespaces except new links in your content.
Can be useful in replacing a string of text that included 1 or more blank spaces with a new value in only certain places.
/[^\S\r\n]+/g
Matches:
- Any spaces but new lines
Non-matches:
- new lines
- abc
- 123
See Also:
- Regex To Match Spaces And Empty Lines That Aren’t In Quotes
- Regular Expression To Match Whitespace
- Regular Expression To Match All Blank Lines In Document
- Regex To Match Any Word In A String Excluding Spaces
- Regular Expressions For New Line
- Regex To Match A String With No Whitespace At The Beginning And End
Rate This Regex
User Review
( votes)Expression Flags
Flags | Description |
---|---|
i |
Ignore case sensitive. |
g |
Allows global search. |
m |
Allows multiline search. |