At 06:24 PM 6/11/01 -0400, Jeff 'japhy' Pinyan wrote:
> >Can anybody suggest me how to match '@' symbol in a regexp to match e-mail
> >ids etc.
>
>I suggest you don't try to write your own email-matching regex. But just
>because you asked, use \@.
This list is a really great experiment in handling questions of this sort
without getting upset and pointing to FAQs and documentation and things
like that, but in some cases, particularly if you are going to suggest
something like the above, a pointer to why is probably in order. (But
still don't get upset. :-)
Writing a regular expression that matches all RFC 822 addresses and nothing
else is really, really hard to do correctly. There are a couple floating
around that at least come close to doing the job, and as you'd expect
people have encapsulated the process and it is available.
CPAN has Email::Valid for checking the validity of email addresses. A
description can be found here:
http://search.cpan.org/doc/MAURICE/Email-Valid-0.13/Valid.pm
That one will also do hostname lookups optionally.
Depending on exactly what you need, if you want a single regular expression
that comes close to doing the job, I remember that Tom Christiansen wrote a
monster of one that either completely determines rfc 822 compatibility or
close a few years back. Searching around the net will likely turn it up.
Cheers,
Jeff