<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Insert title here</title></head><body> <script> var str='Paul,Paula,paul,Ppaul,Paul';//字符串 var result=str.replace(/\bPaul\b/g,"rin…
JS 利用正则表达式替换字符串 博客分类: JavaScript 学习资料 Java代码 收藏代码 JS 利用正则表达式替换字符串 var data = "123123,213,12312,312,3,Caat,cat,dsfsdfs,"; -])*t\b/ig; //•g(全文查找):•i(忽略大小写):•m(多行查找) var res = data.replace(reCat,"AAA"); 输出:,,,,,AAA,AAA,dsfsdfs, var data =…