日期:2014-05-16 浏览次数:20409 次
7,11,1:2,"AAA,BBB,CCC",DDD
7,11,1:2,"AAA@BBB@CCC",DDD
var origin = '7,11,1:2,"AAA,BBB,CCC",DDD'; var after = origin.replace(/(\"\w+),(\w+),(\w+\")/, '$1@$2@$3');
------解决方案--------------------
var str="7,11,1:2,\"AAA,BBB,CCC\",DDD,\"EEE,FFF,GGG\"HHHH";
var m = str.match(/"([^\"]+?)"/ig);
for(var i=0;i<m.length;i++){
str = str.replace(m[i],m[i].replace(/,/ig,"@"));
}
alert(str);
------解决方案--------------------
var str = '7,11,1:2,"AAA,BBB,CCC",DDD';
var reg = /(\".*),(.*),(.*\")/gi;
var str = str.replace(reg, '$1@$2@$3');
alert(str);
------解决方案--------------------
str = '7,11,1:2,"AAA,BBB,CCC,sfd",DDD' str = str.replace(/"\w+(\,\w+)+"/g, function(v){return v.replace(/,/g, "@");});