chenjf5 / note

1 stars 0 forks source link

正则表达式 #11

Open chenjf5 opened 7 years ago

chenjf5 commented 7 years ago

字符串替换,如果“abCDdasd我是”,把bc替换成bc,"abCDdasd我是"

let pattern = new RegExp("(" + term + ")", "gi");
str = str.replace(pattern, "<em>$1</em>");