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?[13578]|1[02])|(?:0?[469]|11)(?!\/31)|(?:0?2)(?:(?!\/3[01]|\/29\/(?:(?:0[^48]|[13579][^26]|[2468][^048])00|(?:\d{2}(?:0[^48]|[13579][^26]|[2468][^048]))))))\/(?:0?[1-9]|[12][0-9]|3[01])\/\d{4}$
Description
will match all dates in mm/dd/yyyy format. takes into account leap-years and months without 31 days.
Matches
2/29/2004 | 07/16/1492 | 12/31/1999
Non-Matches
2/29/2003 | 2/29/2100 | 11/31/2003
Author Rating: The rating for this expression. harold weathervein
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: Leap Year Error Repeated
Name: Rob the Novice Programmer
Date: 9/21/2004 6:38:58 PM
Comment:
You have fixed the Leap year errors for years not divisible by 400, but what about the ones that are? For example, 2/29/2000 doesn't work, and yet it should. Same for 02/29/1600, and so on, and so on.


Title: fixed
Name: harold
Date: 7/21/2004 12:33:44 AM
Comment:
i didn't know that about the `Gregorian calendar'... was a quick fix though.


Title: Leap Year Error
Name: Michael Ash
Date: 7/20/2004 7:20:36 PM
Comment:
If these dates are based on the Gregorian calender then there is an error with leap years. Years evenely divisible by 100 but not evenly divisble by 400 are not leap years. See http://scienceworld.wolfram.com/astronomy/GregorianCalendar.html 2/29/1900 and 02/29/2100 should not match.


Title: Mr.
Name: Jack Daniels
Date: 7/20/2004 6:17:35 PM
Comment:
Good job! Very Useful.


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