Regular Expression Date Validation

Discussion in 'ASP .Net Web Controls' started by Paul Keister, Oct 7, 2003.

  1. Paul Keister

    Paul Keister Guest

    I'm currently using the following regular expression for U.S. date
    validation:

    \d{1,2}/\d{1,2}/\d{4}| \d{1,2}/\d{1,2}/\d{2}

    I could have used

    \d{1,2}/\d{1,2}/\d{2,4}

    but that would allow the case of a three digit year (I wouldn't sleep at
    night!).

    My question is this: Why is it that when I use the inverse pattern, e.g.

    \d{1,2}/\d{1,2}/\d{2}| \d{1,2}/\d{1,2}/\d{4}

    that four digit date strings fail validation? I have a feeling this has
    something to do with regex evaluation rules, but I can't quite puzzle it
    out.

    Just curious,

    Paul Keister
    PJPM
    www.pjpm.biz
     
    Paul Keister, Oct 7, 2003
    #1
    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,350
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,326
    Michael Borgwardt
    May 30, 2004
  3. =?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:
    871
    Alan Moore
    Dec 2, 2005
  4. GIMME
    Replies:
    3
    Views:
    12,020
    vforvikash
    Dec 29, 2008
  5. Ken

    Regular Expression Date Validation

    Ken, Jun 27, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    162
    Kenny
    Jun 27, 2003
Loading...

Share This Page