javascript 正则表达式去空行方法
去除前导和后续空格 /(^\s*)|(\s*$)/g 范例如下: 函数体: String.prototype.trim=function(){ return this.replace(/(^\s*)|(\s*$)/g,''); } 使用方法: var s=' \u4f60\u597d '; alert( s.trim() ); 如果要清楚所有空格,包括中间的,范例如下: var s='a b c '; String.prototype.clearSpacebar=function(){ return this.replace(/\s*/g,''); } alert( '|
下载地址
用户评论