我有一个从Linux邮件日志中获取的字符串,如下所示:
May 20 12:19:28 example-03 amavis[1445]: (01445-15) Passed SPAMMY {RelayedTaggedInbound}, [10.4.3.2]:49488 [10.4.3.2] <offers-john=example.com@example.net> -> <john@example.com>, Queue-ID: C00OZs0w9DB, Message-ID: <5ZCfDBMQyiUjOVD78ZFxg5%3D%3D@example.net>, mail_id: aCUpU0wtUaR, Hits: 15.587, size: 21407, queued_as: dgzikuucQ9i, 438 ms
我需要提取的元素是:
<offers-john=example.com@example.net> -> <john@example.com>
我想让我的正则表达式尽可能简单明了,所以我不想进入正则表达式来处理电子邮件地址格式。尤其是因为重新编写电子邮件格式是一个容易出错的过程!
我试过了:
$row =~ /(<.*> -> <.*>,)/;
但是,尽管存在逗号分隔符,但该语法一直匹配到Message-ID结尾的末尾,输出如下:
<offers-john=example.com@example.net> -> <john@example.com>, Queue-ID: C00OZs0w9DB, Message-ID: <5ZCfDBMQyiUjOVD78ZFxg5%3D%3D@example.net>,