Need help understanding regular expression

Need help understanding regular expression

am 03.08.2005 01:26:45 von joe

Hi,

I have been using a regular expression that I don’t uite understand to
filter the valid email address. My regular expression is as follows:

runat="server"
ControlToValidate="txtEmail"

ValidationExpression="^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0- 9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"
ErrorMessage="Invalid Email address."
Display="None">


Can someone explain me why the email address joe.green@Z-5com.com is
considered an invalid email address?

Also can someone explain me what the above regular expression means?

Thanks,

Joe

Re: Need help understanding regular expression

am 03.08.2005 03:10:08 von Roland Hall

"Joe" wrote in message
news:FC2D56FC-03BF-48D4-9C58-4345CFFADCD6@microsoft.com...
: I have been using a regular expression that I don't uite understand to
: filter the valid email address. My regular expression is as follows:
:
: : runat="server"
: ControlToValidate="txtEmail"
:
:
ValidationExpression="^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0- 9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"
: ErrorMessage="Invalid Email address."
: Display="None">
:

:
: Can someone explain me why the email address joe.green@Z-5com.com is
: considered an invalid email address?
:
: Also can someone explain me what the above regular expression means?

This is not an asp.db related question. It's also ASP.NET and this is a
Classic ASP db group.

^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\ .[a-z]{2,4})$

^ beginning of string
([_a-z0-9-]+) - group any valid character listed within [ ] underscore a to
z 0 to 9 one or more times
(\.[_a-z0-9-]+) - more of the same but put a . (dot) in front and * zero or
more times for one or more times of the preceeding valid characters
@ - add an @ symbol
([a-z0-9-]+)(\.[a-z0-9-]+)* - repeat
(\.[a-z]{2,4}) - dot - any valid character a to z minimum 2, maximum 4
characters

To make your regexp work, you need to set it to ignore the case because the
valid characters are only for lower-case letters and your email address
fails with Z.

Try this:
^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A -Za-z0-9]+$
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp