[英]PHP preg_replace how to combine these two preg statements?
$str = preg_replace('/[\\r\\n!.,\'“”;’?-\s+]/', ' ', $str);
$str=preg_replace('/\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. preg_replace
接受数组作为参数。 The following should be equivalent: 以下内容应相同:
$str = preg_replace(array('/[\\r\\n!.,\'“”;’?-\s+]/', '/\s+\S{1,2}(?!\S)|(?<!\S)\S{1,2}\s+/'), array(' ', ''), $str);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.