Title |
Test
Find
Leap Year
|
Expression |
(15(8[48]|9[26]))|((1[6-9]|[2-9]\d)(0[48]|[13579][26]|[2468][048]))|(([2468][048]|16|3579[26])00) |
Description |
Validates four-digit leap years after 1582 (when Pope Gregory XIII switched to the Gregorian calendar). The last recognized leap year is 9996, so no worries with the y3k bug. |
Matches |
1584, 2000, 2048 |
Non-Matches |
1200, 1580, 1941, 1800 |
Author |
Rating:
Jon Gray
|
Source |
|
Your Rating |
|
Title: Fixed
Name: Jon Gray
Date: 8/8/2007 10:45:19 AM
Comment:
Per Michael's comment, the regex was changed to only validate leap years after and including 1584. Thanks!
Title: Not Quite
Name: Michael Ash
Date: 7/24/2007 10:30:20 AM
Comment:
1200 and 1204 aren't really leap years. Leap years didn't begin until the late 16th century. Here a link dealing the leap year regex http://regexadvice.com/blogs/mash/archive/2004/04/02/300.aspx