Title |
Test
Find
Pattern Title
|
Expression |
^(((((((0?[13578])|(1[02]))[\.\-/]?((0?[1-9])|([12]\d)|(3[01])))|(((0?[469])|(11))[\.\-/]?((0?[1-9])|([12]\d)|(30)))|((0?2)[\.\-/]?((0?[1-9])|(1\d)|(2[0-8]))))[\.\-/]?(((19)|(20))?([\d][\d]))))|((0?2)[\.\-/]?(29)[\.\-/]?(((19)|(20))?(([02468][048])|([13579][26])))))$ |
Description |
Simple American date format mm-dd-yyyy or mm-dd-yy, no time. Date range is 1900 --> 2099. Is enough for my purposes. Incorectly validates 02-29-1900. I created this to validate dates on a web form where the likely range will be 2000-->2020. Seperators can be '.','/' or '-'
Anyone know the rules for operator precedence for regex syntax? |
Matches |
02-29-2004 | 1/31/1997 | 1-2-03 |
Non-Matches |
02-29-2003 | 04-31-2003 | 31-03-05 |
Author |
Rating:
Neil Walls
|
Source |
Neil Walls |
Your Rating |
|
Title: This works great!
Name: Rebecca
Date: 6/20/2014 2:49:03 PM
Comment:
this works as far as I've tested with leap year and different formats for mm/dd/yyyy
Title: Fix for 1900 leap year
Name: Matt
Date: 11/16/2012 4:50:53 AM
Comment:
"^(((((((0?[13578])|(1[02]))[\.\-\/]?((0?[1-9])|([12]\d)|(3[01])))|(((0?[469])|(11))[\.\-\/]?((0?[1-9])|([12]\d)|(30)))|((0?2)[\.\-\/]?((0?[1-9])|(1\d)|(2[0-8]))))[\.\-\/]?(((19)|(20))?([\d][\d]))))|((0?2)[\.\-\/]?(29)[\.\-\/]?((19)?(([2468][048])|(0[48])|([13579][26]))|((20)?([02468][048])|([13579][26])))))$"
Fixes the 2-29-1900 validation problem
Title: Fix for 1900 leap year
Name: Matt
Date: 11/16/2012 4:50:35 AM
Comment:
"^(((((((0?[13578])|(1[02]))[\.\-\/]?((0?[1-9])|([12]\d)|(3[01])))|(((0?[469])|(11))[\.\-\/]?((0?[1-9])|([12]\d)|(30)))|((0?2)[\.\-\/]?((0?[1-9])|(1\d)|(2[0-8]))))[\.\-\/]?(((19)|(20))?([\d][\d]))))|((0?2)[\.\-\/]?(29)[\.\-\/]?((19)?(([2468][048])|(0[48])|([13579][26]))|((20)?([02468][048])|([13579][26])))))$"
Fixes the 2-29-1900 validation problem
Title: Date Validation
Name: Shailesh Panchal
Date: 10/17/2011 4:41:23 AM
Comment:
I found this regex date expression better for my task i really happy with this. Thanks
Title: Date Validation
Name: Shailesh Panchal
Date: 10/17/2011 4:41:05 AM
Comment:
I found this regex date expression better for my task i really happy with this. Thanks