javascript replaceAll

javascript中的replace只会替换第一个匹配

如果要全部替换的话只能重写方法实现replaceAll

记录一下

String.prototype.replaceAll = function (s1, s2) { 
    return this.replace(new RegExp(s1,"gm"),s2);
}

posted @ 2014-05-23 10:17  NewObject_1  阅读(146)  评论(0编辑  收藏  举报