![](/img/trans.png)
[英]PHP combine two preg_replace into one for email and phone hiding
[英]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);
如果我這樣離開它們也存在性能問題或者它是否更好。
preg_replace
接受數組作為參數。 以下內容應相同:
$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.