javascript replace multiple spaces with single space
snippet in javascript

replace multiple spaces with single space javascript

user5113

string = string.replace(/\s\s+/g, ' ');

javascript replace multiple spaces with single space

user4601

var multiSpacesString="I  have     some big    spaces.";
var singleSpacesString=multiSpacesString.replace(/  +/g, ' ');//"I have some big spaces."