If you want to match the whole thing from :
$r = '`<a([^>]+)href="mailto:([^">]+)"([^>]*)>(.*?)</a>`ism';
preg_match_all($r,$html, $matches, PREG_SET_ORDER);
To fastern and shortern it:
$r = '`<a([^>]+)href="mailto:([^">]+)"([^>]*)>`ism';
preg_match_all($r,$html, $matches, PREG_SET_ORDER);
The 2nd matching group will be whatever email it is.
Example:
$html ='<div><a href="mailto:test@live.com">test</a></div>';
$r = '`<a([^>]+)href="mailto:([^">]+)"([^>]*)>(.*?)</a>`ism';
preg_match_all($r,$html, $matches, PREG_SET_ORDER);
var_dump($matches);
Output:
array(1) {
[0]=>
array(5) {
[0]=>
string(39) "test"
[1]=>
string(1) " "
[2]=>
string(13) "test@live.com"
[3]=>
string(0) ""
[4]=>
string(4) "test"
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…