JS过滤空格
1、过滤字符串左右空格:
function String.prototype.Trim() { return this.replace(/(^\s*)|(\s*$)/g, ""); }
2、过滤左空格:
function String.prototype.Ltrim() { return this.replace(/(^\s*)/g, ""); }
3、过滤右空格:
function String.prototype.Rtrim() { return this.replace(/(\s*$)/g, ""); }
4、过滤字符串中所有空格:
function ignoreSpaces(string) {
var temp = "";
string = '' + string;
splitstring = string.split(" ");
for(i = 0; i < splitstring.length; i++)
temp += splitstring[i];
return temp;
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。