Date Regex
Yes I do keep forgetting the regular expression to validate a date. At O’Reilly Answer’s I found a nice article by Jan Goyvaerts. Please read the article. The expression that works best for most of my situations is below.
Match m/d/yy and mm/dd/yyyy, allowing any combination of one or two digits for the day and month, and two or four digits for the year:
^(1[0-2]|0?[1-9])/(3[01]|[12][0-9]|0?[1-9])/(?:[0-9]{2})?[0-9]{2}$
Posted on May 19, 2011, in Regular Expression. Bookmark the permalink. Leave a comment.
Leave a comment
Comments 0