js 扩展方法

String.prototype.replaceAll  = function(s1,s2){return this.replace(new RegExp(s1,"gm"),s2);}
String.prototype.trim=function(){return this.replace(/(^\s+)|\s+$/g,"")}

 

function test(str){

     str = str.trim(); 

     str  = str.replaceAll("," ,"");

}

你可能感兴趣的:(js)