[thelist] Re: regex for email addresses

Peter Barrett Peter.Barrett at corel.com
Tue Oct 15 11:47:01 CDT 2002


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


-----Original Message-----
From: Eduardo Bacchi Kienetz [mailto:eduardobk at via-rs.net]
Sent: Tuesday, October 15, 2002 12:17 PM
To: thelist at lists.evolt.org
Subject: [thelist] Re: regex for email addresses
Importance: High


People, I'm not an expert on regex, but it seems to me that the examples
shown by most (all?) of you would not work for e-mails such as:
eduardo at mydomain.info Yeah, that's right... now we can have e-mails like
that, since we have domains like that ;)

Eduardo Bacchi Kienetz
 From Brazil

--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !



More information about the thelist mailing list