Maison >développement back-end >tutoriel php >一个关于正则去除小数点的问题,请大侠指教
$a = 'aaa,bbb,ccc,"eee,ccc,sss,ppp",dddd,iiii,cccc';
在线等,请大侠来指点。
$a = 'aaa,bbb,ccc,"eee,ccc,sss,ppp",dddd,iiii,cccc';echo preg_replace_callback('/".+?"/', function($r) { return str_replace(',', ' ', $r[0]);}, $a);aaa,bbb,ccc,"eee ccc sss ppp",dddd,iiii,cccc
$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,ccccfunction 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);
楼上都是高手