JavaScript去除空格的三种方法 (trim),RepleaceAll

String.prototype.Trim = function() 
{ 
return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 
 
String.prototype.LTrim = function() 
{ 
return this.replace(/(^\s*)/g, ""); 
} 
 
String.prototype.RTrim = function() 
{ 
return this.replace(/(\s*$)/g, ""); 
}


str.replace(new RegExp(oStr, "gm"), nStr);

你可能感兴趣的:(JavaScript去除空格的三种方法 (trim),RepleaceAll)