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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^[0-9]{4}-(((0[13578]|(10|12))-(0[1-9]|[1-2][0-9]|3[0-1]))|(02-(0[1-9]|[1-2][0-9]))|((0[469]|11)-(0[1-9]|[1-2][0-9]|30)))$
Description
Matches the date format "YYYY-mm-dd" and also validates month and number of days in a month. All leap year dates "YYYY-02-29" passes trough. Could easily be changed to another format.
Matches
2004-04-30 | 2004-02-29
Non-Matches
2004-04-31 | 2004-02-30
Author Rating: The rating for this expression. Johan Södercrantz
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: invalid leap years
Name: Tester
Date: 7/27/2005 3:31:46 AM
Comment:
Your regular expression does not fullt validate leap years... example : 2003-02-29 is validated but it's not an existnig date


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