1、替换第一个字符串:
string.replace("a","b");
2、替换所有字符串
string.replace(/a/g,"b");
3、替换所有key的字符串
string.replace(new RegExp(key,'g'),"b");
1、替换第一个字符串:
string.replace("a","b");
2、替换所有字符串
string.replace(/a/g,"b");
3、替换所有key的字符串
string.replace(new RegExp(key,'g'),"b");
本文标题:js替换字符串
本文链接:https://www.haomeiwen.com/subject/roovvctx.html
网友评论