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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^([1][12]|[0]?[1-9])[\/-]([3][01]|[12]\d|[0]?[1-9])[\/-](\d{4}|\d{2})$
Description
Matches dates with the following format Month - either MM (like 01) or M (like 1) - from 1 to 12 Day - either DD (like 01) or D ( like 1) - from 1 to 31 Year - either YYYY ( like 1998) or YY (like 98) Separater - either - or /
Matches
11-02-02 | 1-25-2002 | 01/25/2002
Non-Matches
13-02-02 | 11.02.02 | 11/32/2002
Author Rating: Not yet rated. Mekonnen Mekonnen
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: February 31 Not Work
Name: Gomathi
Date: 2/26/2010 9:07:58 AM
Comment:
February 31 Not Work for this Expression ^([1][12]|[0]?[1-9])[\/-]([3][01]|[12]\d|[0]?[1-9])[\/-](\d{4}|\d{2})$


Title: Does not accomodate for October. Beware!
Name: Lauree
Date: 9/21/2007 9:45:41 AM
Comment:
Does not accomodate for October. Beware! ^([1][12]|[0]?[1-9])[\/-]([3][01]|[12]\d|[0]?[1-9])[\/-](\d{4}|\d{2})$ ....needed to be.... ^([1][0-2]|[0]?[1-9])[\/-]([3][01]|[12]\d|[0]?[1-9])[\/-](\d{4}|\d{2})$


Title: Double Separater "//"
Name: Sridhar
Date: 7/10/2007 2:51:32 PM
Comment:
It fails for me in the Application when I try with some Invalid Dates it break this Expression. EX: "07//10/2007"


Title: 10th month
Name: Kev
Date: 2/12/2007 7:33:43 AM
Comment:
Hi, Thank you for your good regexp. I think the only point is 10th month. Dear Kubusz thanks for your correction.


Title: October
Name: kubusz
Date: 11/18/2006 9:08:03 AM
Comment:
Hi, your regexp is great, it was very helpful for me, thanks again. But I think it doesn't match 10th month - the beginning should look like: ^([1][012] instead of ^([1][12] the rest is working OK. Thanks again Kubusz


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