javascript multiple replace in one line code example
Example 1: replace multiple spaces with single space javascript
string = string.replace(/\s\s+/g, ' ');
Example 2: javascript replace multiple spaces with single space
var multiSpacesString="I have some big spaces.";
var singleSpacesString=multiSpacesString.replace(/ +/g, ' ');//"I have some big spaces."
Example 3: multiple replace
var str = '[T] and [Z] but not [T] and [Z]';
var result = str.replace('T',' ').replace('Z','');
console.log(result);