Title |
Test
Find
Date in MMDDYYYY
|
Expression |
^((((((0[13578])|(1[02]))[\s\.\-\/\\]?((0[1-9])|([12][0-9])|(3[01])))|(((0[469])|(11))[\s\.\-\/\\]?((0[1-9])|([12][0-9])|(30)))|((02)[\s\.\-\/\\]?((0[1-9])|(1[0-9])|(2[0-8]))))[\s\.\-\/\\]?(((([2468][^048])|([13579][^26]))00)|(\d\d\d[13579])|(\d\d[02468][^048])|(\d\d[13579][^26])))|(((((0[13578])|(1[02]))[\s\.\-\/\\]?((0[1-9])|([12][0-9])|(3[01])))|(((0[469])|(11))[\s\.\-\/\\]?((0[1-9])|([12][0-9])|(30)))|((02)[\s\.\-\/\\]?((0[1-9])|([12][0-9]))))[\s\.\-\/\\]?(((([2468][048])|([13579][26]))00)|(\d\d[2468][048])|(\d\d[13579][26])|(\d\d0[48]))))$ |
Description |
This was made for use in javascript to detect MMDDYYYY formatted text. It tests all valid dates, including 31 vs 30 days in a month and the 28 vs 29 leap year rules which exclude centennial years not divisible by 400 and years not divisible by 4. |
Matches |
02292000 |
Non-Matches |
02291700 |
Author |
Rating:
Ben D
|
Source |
|
Your Rating |
|
Title: Brilliant!
Name: Victoria
Date: 7/28/2010 1:59:36 PM
Comment:
Brilliant approach - no math required! I needed to convert it to YYYYMMDD format; took me a while to figure it out. Very impressive!
Title: WTF?
Name: Randal L. Schwartz
Date: 6/4/2006 12:34:12 PM
Comment:
Why do people try to do MATH with a REGEX? We're back to the 60's or something?