I am sure that someone will write a regex for you that will work. However, why not use Mail::Log::Parse::Postfix (this is a Postfix log right?) and getting the parameters you want is as easy as $logline->{to} .. well almost :)
Regards Gurunandan On Sun, 2009-06-21 at 14:54 +0100, 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? > > > >