var s = 'KPI(年统计|2011-04-15 18:49:04|qqq|www|eee|rrr|ttt|yyy|uuu)KPI(年统计|2011-04-15 18:49:04|qqq|www|eee|rrr|ttt|yyy|uuu)';
var temp;
temp = sreplace(/(kpi\(\))(\)(kpi\(\))/ig,'AB');
alert(temp);
//如果要提取被替换字符串的特征
temp = sreplace(/(kpi\(\))(\)(kpi\(\))/ig,function(){
var $1 = arguments[1],$2 = arguments[2],$3 = arguments[3];;
//$1第一个捕获组,$2第二个捕获组,如只想取前三个字符返回
return $1match(/\w{3}/) + $2 + $3match(/\w{3}/)
});
alert(temp);
欢迎分享,转载请注明来源:品搜搜测评网