📌  相关文章
📜  js替换字符串中的所有符号 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:01:16.899000             🧑  作者: Mango

代码示例1
function replaceAll(str, find, replace) {
    var escapedFind=find.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
    return str.replace(new RegExp(escapedFind, 'g'), replace);
}
//usage example
var sentence="How many shots did Bill take last night? That Bill is so crazy!";
var blameSusan=replaceAll(sentence,"Bill","Susan");