我需要拆分这种字符串来分隔小于和大于< >之间的电子邮件。我正在尝试下一个regex
and preg_split
,但我不工作。
"email1@domain.com" <email1@domain.com>
News <news@e.domain.com>
Some Stuff <email-noreply@somestuff.com>
预期结果将是:
Array
(
[0] => "email1@domain.com"
[1] => email@email.com
)
Array
(
[0] => News
[1] => news@e.domain.com
)
Array
(
[0] => Some Stuff
[1] => email-noreply@somestuff.com
)
我现在使用的代码:
foreach ($emails as $email)
{
$pattern = '/<(.*?)>/';
$result = preg_split($pattern, $email);
print_r($result);
}