Perl regex matching too broadly -


i have strings taken linux mail logs :

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 

the element need extract :

<offers-john=example.com@example.net> -> <john@example.com> 

i want keep regex simple , clear possible, don't want go regex email address formats. not least because regexing email formats bug-prone process !

i have tried :

$row =~ /(<.*> -> <.*>,)/; 

but, despite presence of comma delimiter, syntax matches way end of end of message-id output such :

<offers-john=example.com@example.net> -> <john@example.com>, queue-id: c00ozs0w9db, message-id: <5zcfdbmqyiujovd78zfxg5%3d%3d@example.net>, 

you need make non-greedy adding ? regex :

(<.*?> -> <.*?>) 

demo


Comments