我有这封电子邮件First Last <email@email.com>
如何删除所有内容并返回email@email.com
? - 使用php
答案 0 :(得分:0)
利用Regular Expressions
preg_match_all
<?php
$str='First Last <email@email.com>';
preg_match_all('/<(.*?)>/', $str, $matches);
echo $matches[1][0];
<强> OUTPUT :
强>
email@email.com
答案 1 :(得分:0)
$email = 'First Last <email@email.com>';
$email = preg_replace('/^.*<(.*?)>$/', '\1', $email);
答案 2 :(得分:0)
这会对你有帮助,
<?php
$string = "First Last <email@email.com>";
$pattern = '/([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])' .
'(([a-z0-9-])*([a-z0-9]))+' . '(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)/i';
preg_match ($pattern, $string, $matches);
echo $matches[0];
?>