javascript正则表达式 实现Trim()

javascript正则表达式 实现Trim()

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

TrimLeft()

String.Prototype.trimLeft=function(){
return this.replace(/(^\s*)/,"");
}

trimRight()

String.prototype.trimRight()=funtion(){
return this.replace(/(\s*$)/,"");
}
原文地址:https://www.cnblogs.com/philzhou/p/1814885.html