用JS实现去掉空格功能
//去两边空格
String.prototype.trim = function(){
return this.replace(/(^\s*)|(\s*$)/g, "");
};
//去所有空格
String.prototype.trimAll = function(){
return this.replace(/(^\s*)|(\s*)|(\s*$)/g, "");
};
发布时间: 2012-12-18 12:43:41 作者: rapoo
用JS实现去掉空格功能
//去两边空格
String.prototype.trim = function(){
return this.replace(/(^\s*)|(\s*$)/g, "");
};
//去所有空格
String.prototype.trimAll = function(){
return this.replace(/(^\s*)|(\s*)|(\s*$)/g, "");
};