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

All using regex in tools commands · Regular expressions pcre2 cheatsheet

Was this page helpful?