当前位置: 代码迷 >> JavaScript >> JS 利用正则表达式轮换字符串
  详细解决方案

JS 利用正则表达式轮换字符串

热度:74   发布时间:2013-08-21 10:42:06.0
JS 利用正则表达式替换字符串
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=