javascript replaceAll

mac2022-06-30  67

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

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)