-----Original Message----- >From: [EMAIL PROTECTED] >Sent: Jan 30, 2008 4:58 AM >To: beginners@perl.org >Subject: Re: How to read an rfc spec > >On Jan 28, 2:27 pm, [EMAIL PROTECTED] wrote: >> Hi everyone >> It cost nothing to be polite and only a few seconds to be helpful. I was >> myself looking at RFC822 a few days ago to try to figure out what headers >> should be in an >> email message I bounce with my Perl re-wtite script from a procmail recipe. >> Secret formats and being generally unhelpful are a M$ trait, not to be >> cloned. >> -- >> Andrew in Edinburgh,Scotland. >And to close the issue. > >Was looking for info on the email RFC too and ran into this. > >http://www.regular-expressions.info/email.html > >and the "final" word on the matter. Do read what he has to say but >here is the monster regx > >$emailx = qr((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=? >^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\ >[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])? >\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]? >[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a- >z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01- >\x09\x0b\x0c\x0e-\x7f])+)\])); >
This RE is not perfect as it was said on this list. You may use a module from CPAN instead: http://search.cpan.org/~rjbs/Email-Valid-0.179/lib/Email/Valid.pm EXAMPLES ^ Let's see if the address '[EMAIL PROTECTED]' conforms to the RFC822 specification: print (Email::Valid->address('[EMAIL PROTECTED]') ? 'yes' : 'no'); -- Jeff Pang - [EMAIL PROTECTED] http://home.arcor.de/jeffpang/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/