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?
Thanks.
Don't do that. Use a module, such as Email::Valid, that actually gets it
right.
Ben
> if(/^[A-z0-9]+([_\.][A-z0-9\-]+)* ...
The problem is A-z here, A-z contains all of
ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz
so it matches the underscore in the email address.
To match only letters, you should use [A-Za-z0-9] instead.
Sure.
if (/_/) {
print "$_ is invalid";
}
else {
print "$_ is valid";
}
Abigail
--
echo "==== ======= ==== ======"|perl -pes/=/J/|perl -pes/==/us/|perl -pes/=/t/\
|perl -pes/=/A/|perl -pes/=/n/|perl -pes/=/o/|perl -pes/==/th/|perl -pes/=/e/\
|perl -pes/=/r/|perl -pes/=/P/|perl -pes/=/e/|perl -pes/==/rl/|perl -pes/=/H/\
|perl -pes/=/a/|perl -pes/=/c/|perl -pes/=/k/|perl -pes/==/er/|perl -pes/=/./;
An e-mail address with _ (or ._ or _.) isn't invalid, AFAIK.
Frank
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
But that wasn't what he asked.
He wanted to filter out three particular email addresses.
Abigail
--
my $qr = qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
$qr =~ s/$qr//g;
print $qr, "\n";
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