[nycphp-talk] RegExp Assistance
Timothy Boyden
tboyden at supercoups.com
Thu Mar 1 11:11:18 EST 2007
Any RegExp gurus care to do an educational breakdown of the RegEx filter
in that function?
I just can't get my head around regular expressions, too much like
algebra and Perl ;-p
TIA,
Tim
-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org]
On Behalf Of Alvaro P.
Sent: Thursday, March 01, 2007 10:57 AM
To: NYPHP Talk
Subject: Re: [nycphp-talk] RegExp Assistance
I use this function:
function validateEmail(email)
{
var
filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z
]{2})?)$/i;
if(filter.test(email)==true) {
return true;
} else{
return false;
}
}
Alvaro
Peter Sawczynec wrote:
> I am currently using this regexp noted below to validate client-side
> before the user submits so that at least their email is well-formed:
>
> var emailRegxp = /^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/;
> if( emailRegxp.test(strng) != true ){
> return false;
> }else{
> return true;
> }
>
> But, this regexp is not accepting emails of the form name at tom-cat.com
> <mailto:name at tom-cat.com> It is rejecting the hyphen in the domain
> name.
>
> Does anyone have a real-life tested simple regexp that would plug into
> the snippet above and be more complete?
>
> Thanks to all.
>
> Warmest regards,
>
> Peter Sawczynec
> Technology Dir.
> Sun-code.com
> Web related services
> 646.316.3678
> ps at sun-code.com <mailto:ps at sun-code.com>
>
> ----------------------------------------------------------------------
> --
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php
More information about the talk
mailing list