开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜