1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| var testStr="ab
cd";
var resultStr=testStr.replace(/\ +/g,"");
resultStr=testStr.replace(/[ ]/g,"");
resultStr=testStr.replace(/[\r\n]/g,""));
resultStr= testStr.replace(/(\n)/g, ""); resultStr= testStr.replace(/(\t)/g, ""); resultStr= testStr.replace(/(\r)/g, ""); resultStr= testStr.replace(/<\/?[^>]*>/g, ""); resultStr= testStr.replace(/\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,''); }
function is_digitals(str) { var reg=/^[0-9]*$/; //匹配整数 return reg.test(str); }
|