regex replace whitespace with single space code example
Example 1: replace multiple spaces with single space javascript
string = string.replace(/\s\s+/g, ' ');
Example 2: regex ignore spaces
\s* ignore spaces
eg \s*yourregex\s*
string = string.replace(/\s\s+/g, ' ');
\s* ignore spaces
eg \s*yourregex\s*