Regex for Matching Multiple Consecutive Spaces
Matches two or more consecutive space characters, useful for collapsing them into one.
Published October 12, 2026
Matches two or more consecutive space characters, useful for collapsing them into one.
Key points
- Commonly used with a replace operation, substituting all matches with a single space
Example
\s{2,}