
使用正则即可,例如下面的替换
var procContent = content.replace(new RegExp("<br/>", "gm"), "<br>");
也可以使用一个扩展方法
String.prototype.replaceAll = function(before, new) {
return this.replace(new RegExp(before, "gm"), new);
}
使用
var str = "dogdogdog";
var str2 = str.replaceAll("dog", "cat");
console.log(str2);
评价