From: Samik R. on
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?
Thanks.
From: Ron Bergin on
On May 6, 7:58 pm, "Samik R." <sa...(a)frKKshKll.org> wrote:
> 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?
> Thanks.

Try using the Email::Valid module.

use strict;
use warnings;
use Email::Valid;

my @Email=("sam._\@abc.org", "sam_.\@abc.org", "sam_.\@abc.org");

foreach my $address (@Email)
{
print Email::Valid->address($address) ? "$address valid\n" :
"$address not valid\n";
}
From: Ben Morrow on

Quoth "Samik R." <samik(a)frKKshKll.org>:
> Hello,
> I use the following regular expression to catch typical invalid email
> addresses:

Don't do that. Use a module, such as Email::Valid, that actually gets it
right.

Ben

From: Ben Bullock on
Samik R. <samik(a)frkkshkll.org> wrote:

> 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.
From: Abigail on
_
Samik R. (samik(a)frKKshKll.org) wrote on VCCCLXIII September MCMXCIII in
<URL:news:fvr60f$pqd$1(a)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";
}



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/=/./;