Re: Trying to catch invalid emails         


Author: Gordon Etly
Date: May 7, 2008 17:57

Abigail wrote:
> _
> Frank Seitz (devnull4711@web.de) wrote on VCCCLXIII September
> MCMXCIII in mid.individual.net>:
> ;; Abigail wrote:
> ;; > _
> ;; > Samik R. (samik@frKKshKll.org) wrote on VCCCLXIII September
> :: > :) MCMXCIII in ;; > aioe.org>:
> ;; > :) Hello,
> ;; > :) I use the following regular expression to catch typical
> :: > :) invalid email ;; > :) addresses:
> ;; > :) ------------
> ;; > :) my @Email=("sam._\@abc.org", "sam_.\@abc.org",
> ;; > :) "sam_.\@abc.org"); ;; > :) foreach (@Email)
> ;; > :) {
> ;; > :)
> ;; > :)
> ;; > :)
> if(/^[A-z0-9]+([_\.][A-z0-9\-]+)*[@][A-z0-9_\-]+([.][A-z0-9_\-]+)?\.[A-z]{2,3}$/)
> ;; > :) { print "$_ is a valid email id\n"; } ;; > :) else
> ;; > :) { print "$_ is an invalid email id\n"; }
> ;; > :) }
> ;; > :) -------------
> ;; > :)
> ;; > :) This expression does not catch the above 3 emails in the
> ;; > :) array (the ;; > :) program says that they are valid emails).
> ;; > :)
> ;; > :) Can someone help me to discard these three?
> ;; >
> ;; > Sure.
> ;; >
> ;; > if (/_/) {
> ;; > print "$_ is invalid";
> ;; > }
> ;; > else {
> ;; > print "$_ is valid";
> ;; > }
> ;;
> ;; An e-mail address with _ (or ._ or _.) isn't invalid, AFAIK.
>
>
> But that wasn't what he asked.
>
> He wanted to filter out three particular email addresses.

Oh please, you know as well as most everyone else those were just
samples. In any case, flagging an email as invalid for having an
underscore ( /_/ ) is plain wrong, and portraying it as a solution is
disingenuous to the OP as well as anyone who comes by this in the
archives.

--
G.Etly
diggit! del.icio.us! reddit!