#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    14
    Rep Power
    0

    Regular Expression - date parser problem


    Hi all,

    I use the following regular expression to parse a date:
    Code:
    [0-9][0-9]{0,1}.{1}[0-9][0-9]{0,1}.{1}[0-9]{4}
    This should validate all dates like this:
    10.8.2002
    9.12.1998

    But if I enter this date:
    14.0352001
    or
    14.3a2001
    it validates it too, I don't know why!

    Any solution? Any parser proposition?
    Thanks a lot!
    ::tiago
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    In regex the period ( . ) means "any character". Try this:
    Code:
    [0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{4}

IMN logo majestic logo threadwatch logo seochat tools logo