- The first Regular Expression Library on the Web!

Please support RegExLib Sponsors


Regular Expression Details

Title Test Find Pattern Title
Date with leap years. Accepts '.' '-' and '/' as separators d.m.yy to (or, etc) Ex: dd-mm-yyyy dd/m.yyyy etc etc Accept 00 years also.
29.2.2004 | 31121975 | 29/2-00
29.2.2005 | 32121975 | 29.2/01
Author Rating: The rating for this expression. Dany Lauener
Source This forum has helped, but too much bad regexp for dates. Author:
Your Rating
Bad Good

Enter New 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: Very Goog
Name: Mike
Date: 1/27/2016 5:25:57 AM
Thks Life Saver

Title: Require 4 digit year
Date: 6/27/2008 10:48:20 AM
Is there a version that requires 4 digit years? This one seems to accept 2 digit years.

Title: "\ " unrecognised escape sequence
Name: sushma
Date: 1/4/2008 4:58:45 AM
I am getting ASP.NEt unrecoginized escape error while compilation

Title: one question
Name: alex
Date: 5/28/2007 6:35:15 PM
one question: 09 as yy is 1907 or 2009 and 12 as yy is 1912 or 2012

Title: ASP.NEt unrecoginized escape
Name: C3
Date: 5/23/2006 1:15:41 PM
You need an @ before the regex's to avoid Visual Studio giving you an error. so RegEx.IsMatch(input, @"...");

Title: Other versions?
Name: Geoff Caylor
Date: 8/9/2004 3:19:06 PM
Hello. Great expression! However, I'm looking for one in a different format? Do you have one, or does any other reader know of one that handles the following formats? MMDDYY, MMDDYYYY, MM/DD/YY, MM/DD/YYYY TIA, G

Title: For Mike request
Name: Dany Lauener
Date: 4/13/2004 3:57:44 PM
here it comes. As I discovered into your email that you do not need DDMMYYYY validation, I removed it... se here :

Title: Extend regexp to handle 1 digit year date
Name: Mike
Date: 4/13/2004 9:43:39 AM
After must testing I found this regexp to be the only one to work in all the cases I required, except 1. I need to extend it so that it also accepts 1 digits years (which I will convert with javascript from 0 to 2000, 1 to 2001, etc). I've no experience with regular expression and am finding this probably easy task impossible to complete. Thanks in advance for any help.

Title: Mr
Name: Thomas Keegan
Date: 4/1/2004 4:38:50 AM
Excellent, no better word to describe it

Title: date
Name: pierpaolo
Date: 3/11/2004 2:08:59 PM

Title: dd-mmm-yyyy
Name: Michael Ash
Date: 2/19/2004 10:13:27 AM
Here's one in that format. although it only uses spaces for separators so would still need slight modification

Title: dd-MMM-yyyy
Name: Dany
Date: 2/19/2004 9:11:59 AM
I'll do one for you if I have time. It's easy... I will be longer because not numeric, but whatever... Best regards. Dany

Title: dd-MMM-yyyy
Name: Peter
Date: 2/19/2004 9:07:17 AM
I think this is one of the best regular expressions i have ever seen. Q: What can be done for this to take dates like: "01-Jan-2003" or: "12-Dec-2004" ... ?? or: 14 Feb 2004 ? format for .NET is: "dd-MMM-yyyy" How can this be done?

Title: Doesn't seem to be written for it :)
Name: Dany
Date: 12/8/2003 2:28:18 AM
On earth, there's sometimes something strange. A metric system exists, as well as a "logical" way to go from the smallest part to he biggest : days, then months, then years. DD/MM/YY With a touch of humour.

Title: Got a problem..
Name: Paul S
Date: 12/5/2003 4:25:23 PM
Doesn't seem to work with 13 or higher in the middle group of digits. For example, 02/12/03 works but 02/13/03 does not.

Title: KickAss!
Name: Macca
Date: 12/4/2003 4:04:26 AM
Well-done, and thank you.

Title: Re: Cool, but
Name: Michael Ash
Date: 11/12/2003 9:59:13 AM
Here is one in MM/DD/YYYY format

Title: Cool, but..
Name: TK
Date: 11/11/2003 1:36:57 PM
Can someone please convert this regexp to handle MMDDYYYY instead of DDMMYYYY?

Title: ASP.NET
Name: Bert
Date: 10/30/2003 5:10:28 AM
Does anyone know how to convert the expressions so i dont get the unrecognized escape sequence error. When i copy them into a string i currently i have the error saying unrecognized escape sequence.

Name: Tony
Date: 10/30/2003 4:47:01 AM
That reg ex is fantastic... It works so nicely and is extremely extensive... EXCELLENT WORK my good man

Title: Jakarta regexp
Name: Dany Lauener
Date: 9/26/2003 3:08:13 AM
Hi Thiago, try to replace [\.\-\/] with [:punct:] you can find docs about regexp in jakarta here : or java help here: Please, note that this regexp should be java compliant. Note also the "red" issues of jakarta. Hope this helps. Dany

Title: True coder spirit shown
Name: Henrik
Date: 9/20/2003 7:12:26 AM
Hi Dany Thank you for this extremely useful regex. I'm a CTO in a software company, where the pressure hits the roof every day and have no time to sit down and create an expression like this. I'm going to use it in a high profile app for a Scandinavian company. You have already been credited. Thanks again.

Title: Your welcome
Name: Dany
Date: 9/16/2003 8:51:39 AM
Your welcome guys ! The secret is to separate your expression into very simple working (and 100% tested) regexp, and then respect the logical way to construct a bigger one, and so on... If you wan, I've got a file with separated expressions (basic month validator, for example, then day validator, then leap year, then non leap year, etc...) send me a mail.

Title: Cool - at last the one that seems to work in all cases
Name: Jacek
Date: 8/9/2003 8:59:21 AM
Thanks for posting this regexp!

Name: Steve
Date: 7/30/2003 10:43:22 AM
Too many posted regex's do not work. AFter testing 12-15 posted regexes, this is the first that I have found that has passed ALL of my tests. It may still fail some, but works better than any I have found so far. Well done Dany!

Copyright © 2001-2018, | ASP.NET Tutorials