js去除字符串空格
str.replace(/\s+/g,"");
str.replace(/\s|\xA0/g,"");
empName=empName.replace(/^\s+/g,""); //去左 empName=empName.replace(/\s+$/g,"") //去右 empName=empName.replace(/(^\s*)|(\s*$)/g, ""); //去左右
//去除空格 String.prototype.Trim = function() { return this.replace(/\s+/g, ""); } //去除换行 function ClearBr(key) { key = key.replace(/<\/?.+?>/g,""); key = key.replace(/[\r\n]/g, ""); return key; } //去除左侧空格 function LTrim(str) { return str.replace(/^\s*/g,""); } //去右空格 function RTrim(str) { return str.replace(/\s*$/g,""); } //去掉字符串两端的空格 function trim(str) { return str.replace(/(^\s*)|(\s*$)/g, ""); } //去除字符串中间空格 function CTim(str) { return str.replace(/\s/g,''); }
you are the best!