[Za-pm] Script
Oskar Pearson
oskar at qualica.com
Wed Jun 4 08:32:35 CDT 2003
H
> > while (<STDIN>) {
> > my ($email_address) = $_ =~ /([^\s<]+\@[^\s>]+)/;
> > print "email_address: $email_address\n";
> > }
>
> That will go wrong on pathalogical cases like this:
>
> [Sat May 24 12:51:37 SAST 2003] SMS "Mr Br@@i Dude" <braaidude at hotmail.com> sent 151 characters to 271234567891
>
> --
> Nick
Agreed; ta. My original script grabbed the email into another variable
and then re-parsed it, which would have been more reliable, but I
was going for "interesting regex" factor :)
How about something like this; it anchors on the end-of-line to
stop people doing something wierd like the following:
[Sat May 24 12:51:37 SAST 2003] SMS "another at user sent 151 characters to 123123123" <braaidude at hotmail.com> sent 151 characters to 271234567891
my ($email_address) = $_ =~ /([^\s<]+\@[^\s>]+) sent [0-9]+ characters to [0-9]+$/;
I'm assuming the email will always be in the form "text name they supply" <email at address>,
never <email at address> "something", but I guess that's a resonable assumption?
Oskar
--
Oskar Pearson <oskar at qualica.com>
Qualica Technologies (Pty) Ltd
web: http://www.qualica.com/
More information about the Za-pm
mailing list