js replaceAll

var str = "dogdogdog";
var str2 = str.replace(/dog/g,"cat");
console.log(str2);

参考:https://blog.csdn.net/fukaiit/article/details/83245943

原文地址:https://www.cnblogs.com/liouzeshuen/p/11910934.html