javascript replaceAll
时间:2014-05-26 10:49:03
收藏:0
阅读:326
javascript中的replace只会替换第一个匹配
如果要全部替换的话只能重写方法实现replaceAll
记录一下
String.prototype.replaceAll = function (s1, s2) {
return this.replace(new RegExp(s1,"gm"),s2);
}
评论(0)