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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Date YYYY-MM-DD including leap year
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])))|((([02468][048]|[13579][26])00|\d{2}([13579][26]|0[48]|[2468][048])))-02-29)){0,10}$
Description
This expression mathes dates formatted as YYYY-MM-DD from 0000-01-01 to 9999-12-31. It checks leap year including all modulo 400, modulo 100 and modulo 4 rules.
Matches
2013-01-14 | 2000-02-29 | 0000-12-12
Non-Matches
2012-02-29 | 966-04-30 | 2013-01-32
Author Rating: The rating for this expression. Radek
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

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