PHP preg_replace how to combine these two preg statements?
$str = preg_replace('/[\\r\\n!.,\'“”;’?-\s+]/', ' ', $str);
$str=preg_replac开发者_如何学JAVAe('/\s+\S{1,2}(?!\S)|(?<!\S)\S{1,2}\s+/', '', $str);
If I leave them like that is there performance issue also or is it better.?
preg_replace
accepts arrays as arguments. The following should be equivalent:
$str = preg_replace(array('/[\\r\\n!.,\'“”;’?-\s+]/', '/\s+\S{1,2}(?!\S)|(?<!\S)\S{1,2}\s+/'), array(' ', ''), $str);
精彩评论