$regex = '([\w-\.]+)@((?:[\w]+\.)+)([a-zA-Z]{2,4})';
$string = 'I am emailing to [email protected] and [email protected] but [email protected]';
$newString = preg_replace($regex,'',$string);
我想用空字符串替換所有的電子郵件地址,只留下前兩個。所以$ newString應該是 I am emailing to [email protected] and [email protected] but
。但徒勞無益。將一個字符串中的所有子字符串替換爲離開第一個字符串的兩個字符串 - PHP
我怎麼辦呢....
你沒問幾乎同樣的事情就在最近? – mario 2013-04-06 22:51:15
您的正則表達式是否正確識別所有電子郵件地址? – Sepster 2013-04-06 22:52:56
使用preg_replace_callback並記錄進行了多少次替換。 – 2013-04-06 23:19:45