EASY buzzhost.co.uk wrote:
OK, I'm an idiot. I just cannot get a simple regex match to work as
intended. I've google, I dug out my books of regex and Perl but I hang
my head in shame and ask here for help;
Take This line;
Jun 14 08:14:41 pingpong postfix/smtpd[22386]: NOQUEUE: reject: RCPT
from host120-109-dynamic.56-82-r.retail.telecomitalia.it[82.56.109.120]:
554 5.7.1 <t...@example.com>: Sender address rejected: spoofing of
domain; from=<t...@example.com> to=<t...@example.com> proto=SMTP
helo=<82.56.109.120>
I'm trying to grab the email address in the 'from=<...' portion. I can
pin this down with look ahead look behind;
(?<=from\=<)....@.+(?=>)
But it has a side effect of going to the last > on the line, not the
closing half of the pair <>.
To knock out the complications I drop to a simple pattern without the
look ahead/behind;
<....@.+>
again it matches all the way to the end of the line, not just the
opening < and closing > as intended.
Now, a little research and I come up with 'greedy -v- non greedy'
matching and thought I was on to something. But I can get that to play
ball either;
<....@.+(.*?)>
But No dice. After 8 hours on this I'm starting to kick myself blue. Can
anyone put me out of my misery?
You need to make both sides of @ non-greedy:
(?<=from=<)....@.+?(?=>)
Or:
<....@.+?>
John
--
Those people who think they know everything are a great
annoyance to those of us who do. -- Isaac Asimov
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/