RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^\d{4}[\-\/\s]?((((0[13578])|(1[02]))[\-\/\s]?(([0-2][0-9])|(3[01])))|(((0[469])|(11))[\-\/\s]?(([0-2][0-9])|(30)))|(02[\-\/\s]?[0-2][0-9]))$
Description
- validates a yyyy-mm-dd, yyyy mm dd, or yyyy/mm/dd date - makes sure day is within valid range for the month - does NOT validate Feb. 29 on a leap year, only that Feb. CAN have 29 days
Matches
0001-12-31 | 9999 09 30 | 2002/03/03
Non-Matches
0001\02\30 | 9999.15.01 | 2002/3/3
Author Rating: The rating for this expression. Rex Po
Source
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Nice RegEx!
Name: Ed Z
Date: 1/9/2008 8:28:49 AM
Comment:
This is the best date RegEx I could find. It is easy to rewrite it to support other date formats. Good job!


Title: Nice RegEx!
Name: Ed Z
Date: 1/9/2008 8:28:40 AM
Comment:
This is the best date RegEx I could find. It is easy to rewrite it to support other date formats. Good job!


Copyright © 2001-2018, RegexAdvice.com | ASP.NET Tutorials