js去除空格(trim方法)
时间:2015-06-23 15:05:26
收藏:0
阅读:276
/**
* 去空格
*/
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,"");
};
原文:http://www.cnblogs.com/rainheader/p/4595309.html
评论(0)