一个关于正则去除小数点的问题,请大侠指教
<br />$a = 'aaa,bbb,ccc,"eee,ccc,sss,ppp",dddd,iiii,cccc';<br />
$a = 'aaa,bbb,ccc,"eee,ccc,sss,ppp",dddd,iiii,cccc';<br />echo preg_replace_callback('/".+?"/', function($r) { return str_replace(',', ' ', $r[0]);}, $a);<br />aaa,bbb,ccc,"eee ccc sss ppp",dddd,iiii,cccc
<br />$a = 'aaa,bbb,ccc,"eee,ccc,sss,ppp",dddd,iiii,cccc';<br />
$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';<br />echo preg_replace('/(?<=")(.+?)(?=")/e', 'str_replace(",", " ", "$1")',$a);