string = string.replace(/ss+/g, ' ');
// replaces space with '_' str = str.replace(/ /g, "_"); // or str = str.split(' ').join('_');
string.replace()