我嘗試創建一個正則表達式來捕獲不包含aaa/bbb的.info/.con結尾的電子郵件。preg_match_all忽略單詞
這是正確的語法嗎?
Eg: // search email ending in .com/.info containing no aaa/bbb
preg_match_all('#((?=.*@.*(?:com|info))(!.*(?:aaa|bbb)).*)#ui', $html, $emails);
爲了得到這個:
[email protected] = no
[email protected] = no
[email protected] = good (address syntax correct + term absent before or after the @)
謝謝您的答覆。
此語法正常工作SEE HERE(謝謝STEMA),除了包含空格的字符串。
e.g:
$string = "[email protected] blah [email protected] blah [email protected] [email protected]";
preg_match_all("#^(?!.*aaa)(?!.*bbb).*@.*\.(?:com|info)$#im", $string, $matches);
親切
可能會有幾封電子郵件來捕獲並且不包含禁止使用的字詞(aaa | bbb)在HTML頁面解析。 – StackOverflowCom 2011-06-06 09:23:47