[thelist] Re:thelist digest, Vol 1 #2677 - 15 msgs

eduardobk at via-rs.net eduardobk at via-rs.net
Tue Oct 15 13:01:01 CDT 2002


As I said, I know little of regex, so, I was just wondering if your regex
would or not let pass: eduardo at mydomain.eduardo
Because it must range from 2 to 4, but not greater.
?

P.S: I havent tested you're regex. Is it for ASP, PHP, sed, awk, perl?
They differ from each other (some).

Thank you,

Eduardo Bacchi Kienetz

Subject: RE: [thelist] Re: regex for email addresses
Date: Tue, 15 Oct 2002 12:45:41 -0400
From: "Peter Barrett" <Peter.Barrett at corel.com>
To: <thelist at lists.evolt.org>
Reply-To: thelist at lists.evolt.org


Ah... I'm pretty sure the regex I supplied will match that address...
The point was to allow extensions of length > 3 after the '.' was it
not?....The only modification I made was to change {2,3} to {2,}, which
does just that.


Actually, when I try it, it seems there may be an error with the rest of
the expression, because the following

		var s = 'eduardo at mydomain.info';
		var re =
/^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,}$/;
		alert(s.match(re));

Seems to matche 'mydomain.' as well as 'eduardo at mydomain.info'. Hm...
I'm not noticing the error of the top of my head... There are sevaral
ways to write regexp's & everyone has their own preference. My
preference would be the following, which is not *exactly* the same as
the above, but I believe it is correct for matching email addys, and
gives a more precise match on the address you supplied

		var re = /^[\w-\.]+@[\w-]+\.[\w-]{2,}$/;


hth,
~pete




More information about the thelist mailing list