📌  相关文章
📜  在javascript代码示例中查找单引号并替换

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

代码示例4
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");