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 =…
java 正则匹配空格字符串 正则表达式截取字符串 需求:从一堆sql中取出某些特定字符串: 比如配置的sql语句为:"company_code = @cc and project_id = @pid ; update t set a = @aa,b=@bb,c=@cd,ttt=@ttt;update t2 set d=@bb"; 我要拿出所有的以@开头的作为变量,并且去重,则如下玩: ps:其中正则匹配空格是 “\s+” public class Test { public stat…
<script type="text/javascript"> //查找字符串中出现最多的字符和出现的次数 var str = 'Thatwheneying its on security.'; function find(str) { var max = 0, c; while(str) { var char = str.charAt(0); var a = str.split(char); var count = str.length - (str = a.join(&…