This seems to only remove 2 spaces
String.prototype .trim=function (){return this.replace(/(^s*)|(s*$)/g,'');}
Method 1:
String.prototype.mm = function (){return this.replace(/s/ g, '');}
Method 2:
var s = "asd ddd bbb sss";
var reg = /s/g;
var ss = s.replace(reg, "");
alert(ss);