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?[1-9]|[0-2][0-9])|(3[01])))|(((0?[469])|(11))[\/|\-]?((0?[1-9]|[0-2][0-9])|(30)))|(0?[2][\/\-]?(0?[1-9]|[0-2][0-9])))[\/\-]?\d{2,4}$
Description
After looking for a date regular expression, I could not find one that meet my need, so I develop one that handles 1 or 2 digets in the month and day and also handle feb up to 29. This will allow both / and - for separators, which is what I needed. I hope this helps others too. Thanks, Cliff Schneide
Matches
1-31-02 | 2-29-04 | 08/1/2004
Non-Matches
2-30-04 | 6/31/04 | 13-11-2004
Author Rating: Not yet rated. Cliff Schneide
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: regex is awful
Name: steve morse
Date: 7/27/2004 12:13:05 AM
Comment:
allows '99999'. In fact allows just about anything.


Title: Allows for Feb 29, but in wrong year
Name: Todd Sturner
Date: 2/24/2004 9:22:27 AM
Comment:
Allows for February 29, but in the wrong years.


Title: existing regexs
Name: Michael Ash
Date: 2/20/2004 10:11:18 AM
Comment:
I don't know why the search didn't find them before but if you browse the date & times patterns there are regexs here that match. The following also correctly handle leap years. mm/dd/yy - http://www.regexlib.com/REDetails.aspx?regexp_id=113 and http://www.regexlib.com/RETester.aspx?regexp_id=369 dd/mm/yy - http://www.regexlib.com/REDetails.aspx?regexp_id=151


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