regex remove extra spaces code example
Example 1: replace multiple spaces with single space javascript
string = string.replace(/\s\s+/g, ' ');
Example 2: regex to remove spaces
//..
return str.replace(/\s/g, '');
//..
Example 3: regular expression remove spaces
trim unnecessary whitespace