Re: email validation

2008-11-10 Thread Rob Dixon
Anusha Krishna chand wrote:
>
> How to validate an email id using perl regular expression .

This should help you.

Rob


use strict;
use warnings;

use Regexp::Common 'Email::Address';

my $email_re = $RE{Email}{Address};

foreach (
'"Anusha Krishna chand" <[EMAIL PROTECTED]>',
'"Rob Dixon" <[EMAIL PROTECTED]>',
'beginners@perl.org') {

  print $1, "\n" if /($email_re)/;
}

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: email validation

2008-11-10 Thread Bob McConnell
From: Dermot
> 2008/11/10 Rob Coops <[EMAIL PROTECTED]>:
>> On Mon, Nov 10, 2008 at 11:55 AM, Anusha Krishna chand <
>> [EMAIL PROTECTED]> wrote:
>>
>>> Hi All,
>>>  How to validate an email id using perl regular expression
.
>>>
> ...
>>
>> As for how to actually do that... there are a lot of different ways
and
>> looking at the RFC822 there are very complex email address
posibilities that
>> even many of the major commercial mail servers out there will not
accept
>> because they are so extremely rare that it is easier not to bother
with them
>> then to try and figure out a way to match them.
>> A full fletched way to match all possible types of email addresses
does as
>> far as I am aware not even exist.
>>
>> In any case having a look on cpan <http://search.cpan.org/> might
help
>> though I think you might be better helped havign a look at the email
>> procject <http://emailproject.perl.org/>
> 
> I was sure that there was an FAQ about this that basically said you
> can't just for the reasons that Rob has said. Email addresses of all
> kinds can be valid
> 
> [EMAIL PROTECTED] is a valid email address according
> to RFC822 but in practise will probably be undelivered.
> 
> Formbuilder and HTML::FormFu have email validation pattern.

Linux Journal has an article about email validation with RE in PHP. It
talks about some of the corner and boundary cases in excruciating
detail. It also lists test cases. Perhaps it could be ported to Perl
without too much difficulty.

  <http://www.linuxjournal.com/article/9585>

Bob McConnell

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: email validation

2008-11-10 Thread Dermot
2008/11/10 Rob Coops <[EMAIL PROTECTED]>:
> On Mon, Nov 10, 2008 at 11:55 AM, Anusha Krishna chand <
> [EMAIL PROTECTED]> wrote:
>
>> Hi All,
>>  How to validate an email id using perl regular expression .
>>
...
>
> As for how to actually do that... there are a lot of different ways and
> looking at the RFC822 there are very complex email address posibilities that
> even many of the major commercial mail servers out there will not accept
> because they are so extremely rare that it is easier not to bother with them
> then to try and figure out a way to match them.
> A full fletched way to match all possible types of email addresses does as
> far as I am aware not even exist.
>
> In any case having a look on cpan <http://search.cpan.org/> might help
> though I think you might be better helped havign a look at the email
> procject <http://emailproject.perl.org/>

I was sure that there was an FAQ about this that basically said you
can't just for the reasons that Rob has said. Email addresses of all
kinds can be valid

[EMAIL PROTECTED] is a valid email address according
to RFC822 but in practise will probably be undelivered.

Formbuilder and HTML::FormFu have email validation pattern.

Perhaps the better solution is to get the user to confirm the email
address in a 2nd field.

Dp.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: email validation

2008-11-10 Thread Rob Coops
On Mon, Nov 10, 2008 at 11:55 AM, Anusha Krishna chand <
[EMAIL PROTECTED]> wrote:

> Hi All,
>  How to validate an email id using perl regular expression .
>


First of all it would be nice to see what you tried so far with out that it
seems like you are simply using thsi mailing list as a way to cut corners
during a school/work assignment rather then actually being intrested in the
way the sollution works, or even being willing to bother givving it some
thought your self.

As for how to actually do that... there are a lot of different ways and
looking at the RFC822 there are very complex email address posibilities that
even many of the major commercial mail servers out there will not accept
because they are so extremely rare that it is easier not to bother with them
then to try and figure out a way to match them.
A full fletched way to match all possible types of email addresses does as
far as I am aware not even exist.

In any case having a look on cpan  might help
though I think you might be better helped havign a look at the email
procject 

Regards,

Rob


email validation

2008-11-10 Thread Anusha Krishna chand
Hi All,
  How to validate an email id using perl regular expression .


Re: Email validation syntax

2002-05-01 Thread Randal L. Schwartz

> "Shane" == Shane McElwee <[EMAIL PROTECTED]> writes:

Shane> Below I've a regular expression that checks the syntax of an email address.
Shane> The problem I'm having is with the underscore "_" . I've tried some
Shane> different forms of syntax but I know its something simple I'm missing. I
Shane> think I've been looking at it too long. The validator should allow usernames
Shane> with periods and underscores. Any ideas?

Shane> next if (!/^[\w][\w\._-]*@[\w\.-]+$/)

It's wrong.  Don't use it.  It breaks <*@qz.to> and
, both legitmate addresses in use.

See Email::Valid, or the FAQ.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Email validation syntax

2002-05-01 Thread drieux


On Wednesday, May 1, 2002, at 12:43 , McElwee, Shane wrote:

> Below I've a regular expression that checks the syntax of an email 
> address.
> The problem I'm having is with the underscore "_" . I've tried some
> different forms of syntax but I know its something simple I'm missing. I
> think I've been looking at it too long. The validator should allow 
> usernames with periods and underscores. Any ideas?
>
> next if (!/^[\w][\w\._-]*@[\w\.-]+$/)


since john has pointed out the need to guard the "@" -
let me suggest and underscore the 'unless' syntax -

unless () == if ( !)

At which point you might want to look at:

http://examples.oreilly.com/regex/email-opt.txt

which provides a lovely regular expression solution
for this classic problem


since if you follow John's advice on the faq - you will
notice that you are wandering into the classically simplistic
regEx that will also blow away some 'legitimate' RFC822 and
RFC2822 compliant email addresses -

ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Email validation syntax

2002-05-01 Thread John W. Krahn

Shane McElwee wrote:
> 
> Below I've a regular expression that checks the syntax of an email address.
> The problem I'm having is with the underscore "_".

The \w character class includes the underscore character (\w eq
[a-zA-Z0-9_])

> I've tried some
> different forms of syntax but I know its something simple I'm missing. I
> think I've been looking at it too long. The validator should allow usernames
> with periods and underscores. Any ideas?
> 
> next if (!/^[\w][\w\._-]*@[\w\.-]+$/)
   ^^
perl is interpolating the variable @[ which is probably undefined.  You
_are_ running with "use strict" and "use warnings" aren't you?

next unless /^\w[\w.-]*\@[\w.-]+$/;


BTW, have you read the FAQ "How do I check a valid mail address?" in
perlfaq9?


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Email validation syntax

2002-05-01 Thread Kevin Meltzer

Take a look at Email::Valid

Cheers,
Kevin

On Wed, May 01, 2002 at 03:43:07PM -0400, McElwee, Shane ([EMAIL PROTECTED]) said 
something similar to:
> Below I've a regular expression that checks the syntax of an email address.
> The problem I'm having is with the underscore "_" . I've tried some
> different forms of syntax but I know its something simple I'm missing. I
> think I've been looking at it too long. The validator should allow usernames
> with periods and underscores. Any ideas?
> 
> next if (!/^[\w][\w\._-]*@[\w\.-]+$/)
> 
> Cheers
> 
> Shane
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
All people have the right to be stupid, some people just abuse it!
-- Frank Zappa

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Email validation syntax

2002-05-01 Thread McElwee, Shane

Below I've a regular expression that checks the syntax of an email address.
The problem I'm having is with the underscore "_" . I've tried some
different forms of syntax but I know its something simple I'm missing. I
think I've been looking at it too long. The validator should allow usernames
with periods and underscores. Any ideas?

next if (!/^[\w][\w\._-]*@[\w\.-]+$/)

Cheers

Shane

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Email Validation

2002-02-19 Thread Kevin Meltzer

On Tue, Feb 19, 2002 at 03:53:57PM -0800, Roger Morris ([EMAIL PROTECTED]) said 
something similar to:
> I hadn't found that module when I was searching the net.  the 
> Email::Validdoesn't catch the @this_host.com  It also doesn't catch | 
> in the email, which I would've thought shouldn't be permitted.
> I'll keep digging.

No, it doesn't. But, if I recall, @this_host.com is valid email address syntax,
even though domain names can't (currently) contain the _ character. So,
Email::Valid is sticking to RFC822 (http://www.faqs.org/rfcs/rfc822.html). This
is why I mentioned that Email::Valid has MX host checking, which is where
@host_name.com would fail (since there is not, and can not be a host_name.com
MX record).

Cheers,
Kevin


-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
"I gained nothing at all from Supreme Enlightenment, and for that very
reason it is called Supreme Enlightenment."
-- Gautama Buddha

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Email Validation

2002-02-19 Thread Roger Morris

At 03:35 PM 2/19/2002 -0800, Randal L. Schwartz wrote:
> >>>>> "Roger" == Roger Morris <[EMAIL PROTECTED]> writes:
>
>Roger> I've been working on email validation for a script.  The examples I've
>Roger> seen haven't exactly done that great of a job.  I've taken the code
>Roger> and messed with it some.
>
>But not enough. :)
>
>Roger> sub  valid_email ()
>Roger> {
>Roger> if ($e_address =~ /^\w+(\.\w+){0,}\@\w+(\.\w+){1,}$/i)
>
>That ignores , a valid and active email
>address. (Try it!  It's an autoresponder!)
>
>It permits <[EMAIL PROTECTED]>, an invalid email address.
>
>Definitely wanna look at those other modules.


I hadn't found that module when I was searching the net.  the 
Email::Validdoesn't catch the @this_host.com  It also doesn't catch | 
in the email, which I would've thought shouldn't be permitted.
I'll keep digging.


Roger



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Email Validation

2002-02-19 Thread Randal L. Schwartz

>>>>> "Roger" == Roger Morris <[EMAIL PROTECTED]> writes:

Roger> I've been working on email validation for a script.  The examples I've
Roger> seen haven't exactly done that great of a job.  I've taken the code
Roger> and messed with it some.

But not enough. :)

Roger> sub  valid_email ()
Roger> {
Roger> if ($e_address =~ /^\w+(\.\w+){0,}\@\w+(\.\w+){1,}$/i)

That ignores , a valid and active email
address. (Try it!  It's an autoresponder!)

It permits <[EMAIL PROTECTED]>, an invalid email address.

Definitely wanna look at those other modules.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Email Validation

2002-02-19 Thread Kevin Meltzer

Hi Roger,

Have you looked at the Email::Valid and Mail::Address modules? Mail::Address
will piece apart an email address (address, phrase, etc..) and Email::Valid can
do RFC822 some address validation (including MX host checking).

Cheers,
Kevin

On Tue, Feb 19, 2002 at 11:37:49AM -0800, Roger Morris ([EMAIL PROTECTED]) said 
something similar to:
> I've been working on email validation for a script.  The examples I've seen 
> haven't exactly done that great of a job.  I've taken the code and messed 
> with it some.
> My thoughts were, if the email is in the correct format, 
> ie  [EMAIL PROTECTED]  or some form like   [EMAIL PROTECTED]  then go 
> to the second 'if' statement and check for bad characters.
> It seems to work how I want, have I caught most of the problems?   I'm only 
> interested in the email address, not checking to see if this is 
> valid:  "roger" <[EMAIL PROTECTED]>
> 
> 
> sub  valid_email ()
> {
> if ($e_address =~ /^\w+(\.\w+){0,}\@\w+(\.\w+){1,}$/i)
>   {
>   if ($e_address =~ /\'\{\}\[\]\(\)\$\%\&\\\*/i)
>   {   
>   return 0;
>   }
>   return 1;
>   }
>   return 0;
> }
> 
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
Is that a real poncho or a Sears poncho?
-- Frank Zappa

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Email Validation

2002-02-19 Thread Roger Morris

I've been working on email validation for a script.  The examples I've seen 
haven't exactly done that great of a job.  I've taken the code and messed 
with it some.
My thoughts were, if the email is in the correct format, 
ie  [EMAIL PROTECTED]  or some form like   [EMAIL PROTECTED]  then go 
to the second 'if' statement and check for bad characters.
It seems to work how I want, have I caught most of the problems?   I'm only 
interested in the email address, not checking to see if this is 
valid:  "roger" <[EMAIL PROTECTED]>


sub  valid_email ()
{
if ($e_address =~ /^\w+(\.\w+){0,}\@\w+(\.\w+){1,}$/i)
{
if ($e_address =~ /\'\{\}\[\]\(\)\$\%\&\\\*/i)
{   
return 0;
}
return 1;
}
return 0;
}




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]