String.prototype.trim = function() {
//return this.replace(/[(^\s+)(\s+$)]/g,"");//會把字符串中間的空白符也去掉
//return this.replace(/^\s+|\s+$/g,""); //
return this.replace(/^\s+/g,"").replace(/\s+$/g,"");
}
给js的String添加trim方法
最新推荐文章于 2020-06-26 20:40:58 发布