摘要: 1 if (!String.prototype.trim) {2 String.prototype.trim = function() {3 return this.replace(/^\s+/, "").replace(/\s+$/, "");4 };5 }67 var str = " \t\n test string ".trim();8 console.log(str == "test string");//true混合解决方案:用正则表达式方法过滤头部空白,用非正则表达式的方法过滤尾部字符。 1 Strin 阅读全文
posted @ 2012-06-26 13:52 小猩猩君 阅读(2111) 评论(0) 推荐(0)