-1
發現的電子郵件,我有這樣的代碼找到電子郵件地址,在給定的文本:與preg_match_all
preg_match_all("|[a-zA-Z0-9-_.][email protected][a-zA-Z0-9-]+.[a-zA-Z]+|",
"</b>[email protected] </b> [email protected] ",$out, PREG_PATTERN_ORDER);
和輸出是這樣的:
Array
(
[0] => Array
(
[0] => [email protected]//error one
[1] => [email protected]
)
)
第一個答案是不正確的。爲什麼?
因爲不是一個有效的電子郵件,需要域 – Sal00m
嘗試使用這個正則表達式(在'.'之後的部分):「/[A-Z0-9._%+- ] + @ [A-Z0-9 .-] + \。[AZ] {2,6} \ b/i「 – Ilya
另請參閱:http://stackoverflow.com/questions/201323/using-a-regular-表達式驗證電子郵件地址 – Ilya