On Sun, 2009-06-21 at 07:16 -0700, John W. Krahn wrote:
> 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
> 
John. I love you. I want to have your Babies. Thank you soo much!
I don't understand WHY I have to do that, but it works and at this
moment that is good enough for me!

THANK YOU SIR!


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to