【问题标题】:Regex for parsing email body of forwarded message用于解析转发消息的电子邮件正文的正则表达式
【发布时间】:2012-05-29 04:23:26
【问题描述】:

我需要正则表达式从转发的电子邮件中提取姓名和电子邮件,我要解析的部分可能如下所示(可能缺少某些情况,但这足以开始):

<jill@example.com>, "''Steve Pierce''" <steve@example.com>, "Alex" <alex@example.com>, 'Chris Brown' <chris@example.com>, 'Peter Smith' <peter@example.com>, 'Andy McKay, Jr.' <andyjr@example.com>

【问题讨论】:

标签: php regex email email-validation


【解决方案1】:

试试这个

$result = preg_replace('/<([^<>]+)>, ["\']+([^\'"]+)["\']+/', 'person:$2\r\nmailto:$1', $subject);

【讨论】:

    猜你喜欢
    • 2016-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多