Multiple Whitespace
beginnerMatches sequences of 2+ whitespace characters for collapsing.
whitespacenormalizecleanupformatting
Pattern
/\s{2,}/gTry It
0 of 6 strings matched
Explanation
Matches two or more consecutive whitespace characters. Replace with a single space to normalize whitespace in text.
Test Strings
Matching
- too many spaces
- tab here
- mixed spaces
Non-matching
- single space
- no-spaces
- a b c
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /\s{2,}/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);