var str = "dogdogdog"; var str2 = str.replace(/dog/g,"cat"); console.log(str2);
参考:https://blog.csdn.net/fukaiit/article/details/83245943
js replaceAll
原文:https://www.cnblogs.com/liouzeshuen/p/11910934.html