Need help understanding regular expression

Discussion in 'ASP General' started by Joe, Aug 3, 2005.

  1. Joe

    Joe Guest

    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:

    <asp:RegularExpressionValidator id="valValidEmail"
    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">
    </asp:RegularExpressionValidator>

    Can someone explain me why the email address is
    considered an invalid email address?

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

    Thanks,

    Joe
     
    Joe, Aug 3, 2005
    #1
    1. Advertising

  2. "Joe" <> wrote in message
    news:...
    > 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:
    >
    > <asp:RegularExpressionValidator id="valValidEmail"
    > 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">
    > </asp:RegularExpressionValidator>
    >
    > Can someone explain me why the email address is
    > considered an invalid email address?
    >
    > Also can someone explain me what the above regular expression means?
    >
    > Thanks,
    >
    > Joe
    >

    ^ = Start of Line
    ([_a-z0-9-]+) = One or more underscores, alphanumeric or dashes
    (\.[_a-z0-9-]+)* = Zero or more instances of the following; a period
    followed by one or more underscores, alphanumeric or dashes
    @ = the "at" sign
    ([a-z0-9-]+) = One or more alphanumeric or dashes
    (\.[a-z0-9-]+)* = Zero or more instances of the following; a period followed
    by one or more alphanumeric or dashes
    (\.[a-z]{2,4}) = A period followed by 2, 3 or 4 letters.
    $ = End of Line
     
    Chris Hohmann, Aug 3, 2005
    #2
    1. Advertising

  3. Joe

    Tim Slattery Guest

    Joe <> wrote:

    >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:
    >
    > <asp:RegularExpressionValidator id="valValidEmail"
    >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">
    > </asp:RegularExpressionValidator>
    >
    >Can someone explain me why the email address is
    >considered an invalid email address?


    The RE doesn't allow upper-case letters, so the "Z" after the @ sign
    is probably the culprit.

    I can't tell from this snippet exactly how this RE is being applied.
    VBScript's RegularExpression object has an "IgnoreCase" property. If
    that's set to "true" before the "test" method is run then case doesn't
    matter. This snippet doesn't tell me whether that's being done or not,
    but I can't find any other reason for it to fail.

    There's some Regular Expression documentation here:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vspropattern.asp

    Chris Hohmann's post describes what your RE is looking for. No need
    for me to repeat that.

    --
    Tim Slattery
    MS MVP(DTS)
     
    Tim Slattery, Aug 3, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VSK
    Replies:
    2
    Views:
    2,398
  2. Daniel
    Replies:
    4
    Views:
    425
    Daniel
    Jul 14, 2004
  3. =?Utf-8?B?Sm9l?=

    Need help understanding regular expression

    =?Utf-8?B?Sm9l?=, Aug 3, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,143
  4. =?iso-8859-1?B?bW9vcJk=?=

    Matching abitrary expression in a regular expression

    =?iso-8859-1?B?bW9vcJk=?=, Dec 1, 2005, in forum: Java
    Replies:
    8
    Views:
    886
    Alan Moore
    Dec 2, 2005
  5. GIMME
    Replies:
    3
    Views:
    12,053
    vforvikash
    Dec 29, 2008
Loading...

Share This Page