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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find dd MMM yyyy Date
Expression
^((31(?!\ (Feb(ruary)?|Apr(il)?|June?|(Sep(?=\b|t)t?|Nov)(ember)?)))|((30|29)(?!\ Feb(ruary)?))|(29(?=\ Feb(ruary)?\ (((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))|(0?[1-9])|1\d|2[0-8])\ (Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\b|t)t?|Nov|Dec)(ember)?)\ ((1[6-9]|[2-9]\d)\d{2})$
Description
This RE validates dates in the dd MMM yyyy format. Spaces separate the values.
Matches
31 January 2003 | 29 March 2004 | 29 Feb 2008
Non-Matches
Jan 1 2003 | 31 Sept 2003 | 29 February 2003
Author Rating: The rating for this expression. Michael Ash
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: Converting date to this format
Name: Pamela
Date: 9/22/2021 9:52:20 PM
Comment:
Hi, this is the correct format I need. The date is written December 18, 2020 and I need it to convert to 18-Dec-2020. Can you help me with that please?


Title: Converting date to this format
Name: Pamela
Date: 9/22/2021 9:51:22 PM
Comment:
Hi, this is the correct format I need. The date is written December 18, 2020 and I need it to convert to 18-Dec-2020. Can you help me with that please?


Title: Converting date to this format
Name: Pamela
Date: 9/22/2021 9:48:51 PM
Comment:
Hi, this is the correct format I need. The date is written December 18, 2020 and I need it to convert to 18-Dec-2020. Can you help me with that please?


Title: Best Ever
Name: Peter
Date: 7/24/2012 7:53:40 AM
Comment:
This is the best ever ,just righfor Asp DOTNET and SQL server is ready for this type of date already ..Excellent!


Title: sun
Name: suraj
Date: 7/24/2012 7:31:52 AM
Comment:
sun are like


Title: RE: One bug
Name: Michael Ash
Date: 5/9/2009 11:12:53 PM
Comment:
Ditty, this regex does indeed account for leap years as shown in the last sample match and non-match.


Title: One bug
Name: Ditty Dominique
Date: 3/17/2009 3:40:11 AM
Comment:
This has a bug, it does not take into consideration leap years.


Title: VALIDATION
Name: KINGSTON
Date: 8/14/2008 10:48:34 AM
Comment:
SUPER


Title: Re: case insensitive modification & Sept
Name: Michael Ash
Date: 12/2/2005 2:43:24 PM
Comment:
Thanks for the catch but the fix to allow Sep is not just placing a ? after Sept. That would allow Sepember to pass. Each instance of Sept would need to be Sep(?=\b|t)t? (?i:) will only work in serverside code. The options are not allowed in the pattern in JScipt, so what is valid serverside may not be clientside. I don't know how Asp.Net dealing with embedded options.


Title: case insensitive modification & Sept
Name: Rob Lauriston
Date: 12/2/2005 2:13:10 PM
Comment:
tiny bug: Sep is rejected because ? is missing after Sept. What modification is needed to make this case insensitive? I tried adding ^(?i)( etc... at the beginning, and it works in some environments, but not as an ASP ValidationExpression System.Web.UI.WebControls.RegularExpressionValidator Visual Studio allows the syntax to be entered, but the debugger catches it. This is off the topic of the expression per se, but I thought I'd ask. Thanks for the expression!


Title: Its Good but i can' t understand it
Name: Ashok
Date: 11/22/2005 8:37:59 AM
Comment:
Thnaks for information exactly what i looking for.... but if you place explanation then it is to be better for the persons ...


Title: Re: 2005/9/29 and don't be 2005/09/29
Name: Michael Ash
Date: 9/29/2005 11:42:44 PM
Comment:
This regex only validate the date format pattern stated in the description. If you need another format please see http://regexadvice.com/blogs/mash/archive/2004/06/17/309.aspx


Title: what about 2005/9/29 and don't be 2005/09/29
Name: jspadmin
Date: 9/29/2005 8:35:39 PM
Comment:
what about 2005/9/29 and don't be 2005/09/29?I need 2005/9/9 and 2005/9/10,I mean ,it will be automatically increased ,but with "0",how to assue?


Title: Focus on this website
Name: Jspadmin
Date: 9/29/2005 8:32:08 PM
Comment:
I am from china,learning RegEx,this website may be useful


Title: Thanx alot Michael
Name: Amit Bajaj
Date: 9/2/2005 5:59:02 AM
Comment:
Thanx for that RE. and making our job simpler.


Title: Re: Bug!
Name: Michael Ash
Date: 3/7/2005 4:41:37 PM
Comment:
Fixed. Thanks for the catch.


Title: Bug!
Name: Try Feb 31
Date: 3/7/2005 4:02:03 PM
Comment:
This expression allows Feb 31 - Ankesh Mehta


Title: Ideal for UK .net development
Name: Miles Doubleday
Date: 1/21/2005 7:22:31 AM
Comment:
Exactly what I was looking for given that date validation in "UK" format doesn't work properly in the ASP.NET validation controls. Worked first time, thank you very much indeed.


Title: Re: how bout mm/dd/yyyy
Name: Michael Ash
Date: 10/27/2004 8:10:49 AM
Comment:
Please see http://blogs.regexadvice.com/mash/archive/2004/06/17/1269.aspx


Title: how bout mm/dd/yyyy
Name: amyan
Date: 10/27/2004 2:45:44 AM
Comment:
i've managed so far, to change the "-" to a "/" heh, dat wasn't a guru thing, what i need help wid is how to format the remaining of it?


Title: re: This is similar to what I want
Name: Michael Ash
Date: 3/18/2004 1:48:27 AM
Comment:
Here you go Danna. I just replaced the spaces with dashes. Just note the month names are case sensitive ^((31(?!-(Apr(il)?|June?|(Sept|Nov)(ember)?)))|((30|29)(?!-F eb(ruary)?))|(29(?=-Feb(ruary)?-(((1[6-9]|[2-9]\d)(0[48]|[24 68][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))|(0 ?[1-9])|1\d|2[0-8])-(Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr (il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sept|Nov|Dec)(em ber)?)-((1[6-9]|[2-9]\d)\d{2})$


Title: Best Ever
Name: Peter
Date: 2/19/2004 11:24:47 AM
Comment:
This is the best ever, just right for ASP DOTNET and SQL Server is ready for this type of date already. Excellent!


Title: askelent !
Name: Imran
Date: 10/13/2003 4:07:13 AM
Comment:
fit !! great work :) thanks a lot


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