javascript replaceAll

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

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

记录一下

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

原文地址:https://www.cnblogs.com/yanjunwu/p/3747068.html