时间:2021-07-01 10:21:17 帮助过:144人阅读
$a = 'aaa,bbb,ccc,"eee,ccc,sss,ppp",dddd,iiii,cccc';
$a = 'aaa,bbb,ccc,"eee,ccc,sss,ppp",dddd,iiii,cccc';aaa,bbb,ccc,"eee ccc sss ppp",dddd,iiii,cccc
echo preg_replace_callback('/".+?"/', function($r) { return str_replace(',', ' ', $r[0]);}, $a);
$a = 'aaa,bbb,ccc,"eee,ccc,sss,ppp",dddd,iiii,cccc';
$new=preg_replace('/"(.+?)"/ies',"replace('\\1')",$a);
echo $new;
//aaa,bbb,ccc,"eeecccsssppp",dddd,iiii,cccc
function replace($str){
$return=str_replace(',','',$str);
return '"'.$return.'"';
}
$a = 'aaa,bbb,ccc,"eee,ccc,sss,ppp",dddd,iiii,cccc';
echo preg_replace('/(?<=")(.+?)(?=")/e', 'str_replace(",", " ", "$1")',$a);