Title |
Test
Find
Pattern Title
|
Expression |
^(((\d{4}((0[13578]|1[02])(0[1-9]|[12]\d|3[01])|(0[13456789]|1[012])(0[1-9]|[12]\d|30)|02(0[1-9]|1\d|2[0-8])))|((\d{2}[02468][048]|\d{2}[13579][26]))0229)){0,8}$ |
Description |
Validates a date expression (or empty value) in CCYYMMDD format, checking a leap year from 00000101 A.D. to 99991231 |
Matches |
20041231 | 20040229 |
Non-Matches |
20043112 | 2003/04/02 |
Author |
Rating:
Not yet rated.
Danny Garber
|
Source |
|
Your Rating |
|
Title: Fails on 19000229
Name: Andy McDonald
Date: 9/16/2004 9:10:32 AM
Comment:
Only centuries divisible by 400 are leap years, e.g. 1900 was not a leap year, so 19000229 should not match this regexp; it does.
One reference: http://www.cryst.bbk.ac.uk/CCSG/resources/Year2000/Leap_year_30Feb.html.