Title |
Test
Find
Pattern Title
|
Expression |
^(?:(?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)|(?:0?2)(?:(?!\/3[01]|\/29\/(?:(?:0[^48]|[13579][^26]|[2468][^048])00|(?:\d{2}(?:0[^48]|[13579][^26]|[2468][^048]))))))\/(?:0?[1-9]|[12][0-9]|3[01])\/\d{4}$ |
Description |
will match all dates in mm/dd/yyyy format. takes into account leap-years and months without 31 days. |
Matches |
2/29/2004 | 07/16/1492 | 12/31/1999 |
Non-Matches |
2/29/2003 | 2/29/2100 | 11/31/2003 |
Author |
Rating:
harold weathervein
|
Source |
|
Your Rating |
|
Title: Leap Year Error Repeated
Name: Rob the Novice Programmer
Date: 9/21/2004 6:38:58 PM
Comment:
You have fixed the Leap year errors for years not divisible by 400, but what about the ones that are? For example, 2/29/2000 doesn't work, and yet it should. Same for 02/29/1600, and so on, and so on.
Title: fixed
Name: harold
Date: 7/21/2004 12:33:44 AM
Comment:
i didn't know that about the `Gregorian calendar'... was a quick fix though.
Title: Leap Year Error
Name: Michael Ash
Date: 7/20/2004 7:20:36 PM
Comment:
If these dates are based on the Gregorian calender then there is an error with leap years. Years evenely divisible by 100 but not evenly divisble by 400 are not leap years. See http://scienceworld.wolfram.com/astronomy/GregorianCalendar.html
2/29/1900 and 02/29/2100 should not match.
Title: Mr.
Name: Jack Daniels
Date: 7/20/2004 6:17:35 PM
Comment:
Good job! Very Useful.