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[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((1[6-9]|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((1[6-9]|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((1[6-9]|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$
Description
dd/MM/yyyy with leap years 100% integrated Valid years : from 1600 to 9999 As usual, many tests have been made. I think this one should be fine.
Matches
29/02/2000 | 30/04/2003 | 01/01/2003
Non-Matches
29/02/2001 | 30-04-2003 | 1/1/2003
Author Rating: The rating for this expression. Dany Lauener
Source mailto:[email protected]
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: error
Name: vikas
Date: 12/1/2012 2:31:10 PM
Comment:
In java it gives error here ^(((0[1-9]|[12]\d error: Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )


Title: Warning:
Name: Rodrigo Maia
Date: 1/28/2010 7:58:20 AM
Comment:
Hello. Tanks a lot. It's almost working so fine. The only exception is in the 29/02. Just work in 2000 year. Does not work to 1980, 1984, 1988 etc.


Title: Excellent Expression
Name: Sakthi
Date: 1/25/2010 6:58:24 AM
Comment:
Hi, Do have any expression to validate whether it is a past or future date. Help me. Thanks....


Title: Good Work
Name: dkot
Date: 3/13/2009 6:06:52 AM
Comment:
Do you have a solution for yyyymmdd Thanks


Title: Does the business
Name: Neil Banton
Date: 11/18/2008 10:16:40 AM
Comment:
Nice one - very useful, seems to work fine so far.


Title: Excellent
Name: Nenad
Date: 3/27/2007 11:57:11 AM
Comment:
Great work Dany. Came in handy on few occasions. Thanks.


Title: Excellent
Name: Nenad
Date: 3/27/2007 11:56:59 AM
Comment:
Great work Dany. Came in handy on few occasions. Thanks.


Title: Nevermind
Name: Kolt
Date: 3/9/2007 4:05:34 PM
Comment:
I read through the comments, and you offered a solution to mm/dd/yyyy in another post. Thanks a lot!


Title: A little modification needed
Name: Kolt
Date: 3/9/2007 2:27:00 PM
Comment:
Hi there, this is wonderful! Over here in Canada though, we use mm/dd/yyyy. Can you provide an alternative for this format? Also, my program needs to accept dates that have the month and/or day in a single digit format. For example: mm/dd/yyyy accepts: 02/13/1986 2/13/1986 02/01/1986 02/1/1986


Title: Answer question
Name: Dany Lauener
Date: 9/5/2005 7:25:18 AM
Comment:
Yep, Try with a "begin line" + "end line" and group the "choice |" ^(0?[13578]|1[02])$


Title: Question Mark question
Name: Talon
Date: 9/1/2005 4:11:28 PM
Comment:
Can anyone tell me why 0?[13578]|1[02] or 0{0,1}[13578]|1[02] rejects "10" or "12"? I'm using .NET, btw (don't know if that matters).


Title: GREAT WORK
Name: Beginend
Date: 5/19/2005 10:21:25 AM
Comment:
Thanks for your contribution. It works very well!


Title: Validating dates
Name: mm
Date: 4/6/2005 7:55:37 PM
Comment:
do you know how to validate dates between 1989 and today's date + 1 year


Title: Here it comes Gel
Name: Dany
Date: 3/29/2005 6:39:26 AM
Comment:
MM/dd/yyyy with leap years starting from year 2000. http://www.regexlib.com/REDetails.aspx?regexp_id=1038 Enjoy


Title: Gel, any particular year restriction ?
Name: Dany Lauener
Date: 3/29/2005 6:21:22 AM
Comment:
Hi Gel, Do you need specific year "from" date ? example year 1600, or is year 2000 a good starting point ? Let me know quickly if you want it fast :) Cheers Dany


Title: mm/dd/yyyy format
Name: gel
Date: 3/24/2005 1:11:12 AM
Comment:
hi. do you have any validators (you made) for the mm/dd/yyyy format?


Title: Here it is
Name: Dany Lauener
Date: 3/3/2005 9:33:01 AM
Comment:
Posted for you : years 1900 to 9999 http://www.regexlib.com/REDetails.aspx?regexp_id=1019 just replaced : 1[6-9]|[2-9]\d)\d{2} with : 19|[2-9]\d)\d{2} Cheers. Dany


Title: year restricion
Name: deepills
Date: 3/3/2005 7:02:22 AM
Comment:
Your expression is perfect!But I want to accept only years greater than 1900. How do i do that??Pls help!!


Title: How about mm/dd/yyyy format?
Name: TK
Date: 2/25/2005 10:12:33 AM
Comment:
Can you plz guide me the reg exp if the date format is mm/dd/yyyy? Thanks in advance, V. Thandava Krishna


Title: Rock Solid
Name: Hafeez Abdul
Date: 2/10/2005 12:32:40 AM
Comment:
works perfect for my scenario ta [email protected]


Title: My apologize
Name: Bastiaan
Date: 11/11/2004 1:15:38 PM
Comment:
Hy Dany I made a mistake Your solution is working fine


Title: Problem with month with 31 days
Name: Bastiaan
Date: 11/10/2004 5:40:52 AM
Comment:
I discovered that dates like 31/10/2004 and 31/09/2004 are pointed as having errors Can it be corrected


Title: Good Job
Name: [email protected]
Date: 11/8/2004 6:59:35 AM
Comment:
HY Dany Thanks for your good job.


Title: totally nice
Name: Adam
Date: 10/26/2004 10:34:13 AM
Comment:
works a treat - great work Dany


Title: great code!!!!
Name: Anjali
Date: 9/29/2004 6:26:36 AM
Comment:
This code is great!!! I found it very useful. Thanks Dany!


Title: To allow omission of leading 0's
Name: AlVet
Date: 8/9/2004 11:52:40 AM
Comment:
Works great...but my app doesn't force leading 0's on month and day. To get around that, add {0,1} immediately after the month and day 0's. First match changes from: ^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((1[6-9]|[2-9]\d )\d{2}))|(( To: ^(((0{0,1}[1-9]|[12]\d|3[01])\/(0{0,1}[13578]|1[02])\/((1[6-9]|[2-9]\d )\d{2}))|((


Title: 31/04/2000 passes it should not
Name: Airton
Date: 8/6/2004 12:38:30 PM
Comment:
31/04/2000 passes it should not


Title: Mr
Name: Ruari
Date: 7/27/2004 9:57:18 AM
Comment:
Cool, thanks Dany, this has really helped me.


Title: Perfect solution
Name: Bob
Date: 6/30/2004 9:38:26 AM
Comment:
Dany you RE is exactly what I needed! Thanks for the timesaver.


Title: Bingooo
Name: Parag
Date: 5/26/2004 1:12:59 AM
Comment:
helped me to reduce the my job..of validating.. thanks buddy..


Title: There is a way
Name: Dany Lauener
Date: 12/10/2003 3:26:39 AM
Comment:
I posted a new one, here it is : http://www.regexlib.com/REDetails.aspx?regexp_id=488


Title: Is there a way...
Name: Rob
Date: 12/9/2003 11:23:27 AM
Comment:
Is there a way to make it work for 01/01/01? Thanks in advance!


Title: Well done!! Dany
Name: CALVIN
Date: 10/14/2003 4:26:26 AM
Comment:
Accidently, i found your contribute & solve my problem. Thank you!


Title: WORKS for 01/01/2001
Name: Dany Lauener
Date: 10/14/2003 3:40:27 AM
Comment:
Hi, Please, retest it ! It works well for 01/01/2001.... but not for 01/01/01 CU Dany


Title: does not work for 01/01/2001
Name: Functoid
Date: 10/13/2003 4:23:54 PM
Comment:
does not work for 01/01/2001


Title: awesome
Name: sam
Date: 10/8/2003 1:43:16 PM
Comment:
This is awesome! thanks.


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