标签:
JS 利用正则表达式替换字符串 博客分类: JavaScript 学习资料 Java代码 收藏代码 JS 利用正则表达式替换字符串 var data = "123123,213,12312,312,3,Caat,cat,dsfsdfs,"; var reCat = /\bc([a-z]|[A-Z]|[0-9])*t\b/ig; //•g(全文查找);•i(忽略大小写);•m(多行查找) var res = data.replace(reCat,"AAA"); 输出:123123,213,12312,312,3,AAA,AAA,dsfsdfs, var data = "src=\"http://img6.nanhao360.com/p11/20130812/962-b82c-2b.jpg\" height="; var reCat = /\bhttp:\/\/([a-z]|[A-Z]|[0-9]|\/|\.|-)*\.([jpg]|[png]|[gif])+\b/ig; var res = data.replace(reCat,"AAA"); 输出:src="AAA" height=
标签:
原文地址:http://www.cnblogs.com/archoncap/p/5400883.html