Title |
Test
Find
Pattern Title
|
Expression |
^([01][012]|0[1-9])/([0-2][0-9]|[3][0-1])/([0-9][0-9][0-9][0-9])$ |
Description |
Regular expression that only allows expression in the format: MM/DD/YYYY |
Matches |
01/01/2004 |
Non-Matches |
1/1/04 | 01/01/04 | 03/32/2004 |
Author |
Rating:
David Vander Leest
|
Source |
|
Your Rating |
|
Title: Just what I needed!
Name: Ejen
Date: 7/18/2006 4:36:55 AM
Comment:
Short, sharp and exactly I was looked for. Thanks for a good job!
Title: Slight Modification
Name: Syarzhuk
Date: 4/19/2005 11:38:48 AM
Comment:
I rewrote it as:
^([01][012]|0?[1-9])/([0-2]?[0-9]|[3][0-1])/([0-9]{4})$
1 - allow single digit month
2 - allow single digit year (so that 2/2/2005 matches)
3 - shorten the year expression
Sincerely,
Syarzhuk ([email protected])