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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Reg Ex for Date with Leap Year
Expression
/^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/
Description
Enter the date in MM/DD/YYYY format. This regular expression validates the day, month and year including the leap year validations.
Matches
02/29/2004
Non-Matches
02/31/2004
Author Rating: Not yet rated. Nikhil Shinde
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: Already posted
Name: Michael Ash
Date: 9/17/2007 11:11:20 AM
Comment:
This is almost an identical copy of my regex http://regexlib.com/REDetails.aspx?regexp_id=369 the only difference is this one only allows one type of date field separator (/) where the original gave you three choices. If you are going to modify someone else's work you should give them credit in the "source" field.


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