📜  javascript replaceall string - Javascript 代码示例

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

代码示例6
function name(str,replaceWhat,replaceTo){
    replaceWhat = replaceWhat.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
    var re = new RegExp(replaceWhat, 'g');
    return str.replace(re,replaceTo);
}