Regular expressions pcre2 · Using regex in tools
Replace in JavaScript
Replace every run of whitespace with a single space. The g flag replaces all matches.
text.replace(/\s+/g, " ")
Official Regular expressions pcre2 documentation
More using regex in tools commands
- Search with grep
- Use lookarounds with grep
- Rewrite text with sed
- Match in JavaScript
- Find all matches in Python
- Replace in Python
All using regex in tools commands · Regular expressions pcre2 cheatsheet