我的github
var str = "dogdogdog";
var str2 = str.replace(/dog/g,"cat");
console.log(str2);

参考:https://www.jb51.net/article/23762.htm?tdsourcetag=s_pcqq_aiomsg

str = "dog dog dog12";
str = str.replace(new RegExp("[d]","gm"),"_");
console.log(str);

输出:_og _og _og12

 参考:https://www.runoob.com/jsref/jsref-obj-regexp.html

javascript - 如何使用正则表达式在指定字母(即A、D、F、R)和数字之间插入括号?

参考:https://stackoverflow.com/questions/76403788/

 

posted on 2024-01-26 11:48  XiaoNiuFeiTian  阅读(10)  评论(0编辑  收藏  举报