/* 把 content 中所有的 searchValue 替换为 replaceValue */ function replaceAll(content,searchValue,replaceValue){ while (content.indexOf(searchValue)>-1) { content = content.replace(searchValue,replaceValue); } return content; }
content.replace(new RegExp(searchValue,‘g‘),replaceValue)
原文:https://www.cnblogs.com/anyjs/p/12297431.html