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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find yy/mm/dd Date
Expression
^(?:(?:(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\/|-|\.)(?:0?2\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\d)?\d{2})(\/|-|\.)(?:(?:(?:0?[13578]|1[02])\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\2(?:0?[1-9]|1\d|2[0-8]))))$
Description
This expression validates dates in the y/m/d format from 1600/1/1 - 9999/12/31. Follows the same validation rules for dates as my other date validator (m/d/y format) located in this library.
Matches
04/2/29 | 2002-4-30 | 02.10.31
Non-Matches
2003/2/29 | 02.4.31 | 00/00/00
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: http://www.kobe7playoff.com/
Name: kobe 7
Date: 5/18/2012 2:09:55 AM
Comment:
http://www.kobe7playoff.com/ http://www.kobe7playoff.com/nike-lebron-9ix-c-24.html http://www.kobe7playoff.com/dwyane-wade-shoes-c-15.html


Title: http://www.myairmax2012shoesoutlet.com/
Name: nike air max mens
Date: 5/17/2012 11:59:07 PM
Comment:
http://www.myairmax2012shoesoutlet.com/ http://www.myairmax2012shoesoutlet.com/nike-air-max-2012-c-1.html http://www.myairmax2012shoesoutlet.com/nike-air-max-2011-c-4.html


Title: http://www.roseshoesoutlet2012.com
Name: Adizero Rose 1.0
Date: 5/17/2012 11:48:03 PM
Comment:
http://www.roseshoesoutlet2012.com http://www.roseshoesoutlet2012.com/adidas-adizero-rose-10-c-2.html http://www.roseshoesoutlet2012.com/adizero-crazy-light-c-3.html


Title: http://www.karendresses.com
Name: Karen Millen
Date: 8/17/2011 5:54:33 AM
Comment:
My dear friends, do you want to be more sexy in people's eyes? Just come in, please! We are international trade that specializes in the <a href="http://www.karendresses.com">Karen Millen Dresses</a>. Karen Millen is your best choice! Our products are authentic quality with original box. <a href="http://www.karendresses.com">Discount Karen Millen </a>will cost you less money. So, please don’t hesitate, just contact us for details ! We will be your reliable business partner! Welcome to our website:==http://www.karendresses.com== Thank you!


Title: arabic date
Name: asaad
Date: 3/23/2010 8:25:46 AM
Comment:
hi i want regex for arabic date start from 1400/01/01 to 9999 please send me on my email as soon as possible asad.najam@yahoo.com


Title: No delimeters
Name: Shounak
Date: 10/12/2006 8:29:56 AM
Comment:
Hi this regex is perfect for me.but my date is YYYYMMDD. I dont need any delimiters. What is the modification needed in this regex?


Title: Re: other format
Name: Michael Ash
Date: 3/31/2005 10:27:10 AM
Comment:
Please see http://blogs.regexadvice.com/mash/archive/2004/06/17/1269.aspx


Title: other format
Name: LeSmou
Date: 3/30/2005 10:38:42 AM
Comment:
Hi guys, anyone of you can tell me the regex for the format 'dd.mm.yyyy', i'm not that fit in regexp's to do that :) Thanks in advance, LeSmou


Title: Re: Matching on almost ANY year
Name: Mike Lowe
Date: 8/30/2004 4:36:59 PM
Comment:
Thank you so much! Works great.


Title: Re: Matching on almost ANY year
Name: Michael Ash
Date: 8/30/2004 2:13:39 PM
Comment:
Try it now. It should be fixed


Title: Matching on almost ANY year
Name: Mike Lowe
Date: 8/30/2004 12:52:23 PM
Comment:
When I test this, it appears that it validates almost any year as valid. For example, 030/10/05 193/10/05 200040343/10/05 all validate as a match.... Any way to get the year portion to only match 1600 - 9999 years?


Title: Re: Thanks a lot
Name: Michael Ash
Date: 8/17/2004 10:46:26 AM
Comment:
Basically the (?:...) construct prevents the regex engine from remembering value matched inside the parenthesis Normally the value match inside of parenthesis, a group or submatch, is stored for later use, a backreference.


Title: Thanks a lot
Name: Joe
Date: 8/16/2004 5:07:32 PM
Comment:
Thanks very much! But I still don't understand how to use ?: Please give me a lesson if you have time.


Title: Re: How to validate month and day
Name: Michael Ash
Date: 8/16/2004 4:39:55 PM
Comment:
Here is a 1900-1999 version with leap years for that period still intact ^(?:(?:(?:(?:19)(?:0[48]|[2468][048]|[13579][26])))(\/|-|\.)(?:0?2\1(?:29))$)|(?:(?:19)\d{2})(\/|-|\.)(?:(?:(?:0?[13578]|1[02])\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\2(?:0?[1-9]|1\d|2[0-8]))$


Title: Re: How to validate month and day
Name: Michael Ash
Date: 8/16/2004 4:32:20 PM
Comment:
Ha Ha! This year there were 29 days in February. Anyway try http://www.regexlib.com/REDetails.aspx?regexp_id=95 it always allows Feb 29 but you should be able change that to suit your needs.


Title: How to validate month and day
Name: Joe
Date: 8/16/2004 4:17:57 PM
Comment:
Or how can I modify your code to only validate year 1900 - 1999?


Title: How to validate month and day
Name: Joe
Date: 8/16/2004 4:01:25 PM
Comment:
Thanks for your quick reply. How about I assume there is only 28 days in Feb. Like if this is only for this year. Thanks.


Title: re: How to validate only month and day
Name: Michael Ash
Date: 8/16/2004 2:52:57 PM
Comment:
If you don't validate leap year you can't validate days in Feb.


Title: How to validate only month and day
Name: Joe
Date: 8/16/2004 2:34:38 PM
Comment:
How to validate only month and day? forget about the leap year.


Title: good
Name: wp
Date: 7/13/2004 4:46:45 AM
Comment:
very good,my like


Title: ISO 8601
Name: Igor
Date: 4/13/2004 5:16:29 AM
Comment:
This Pattern is ideal for ISO 8601 date format.


Title: GREAT
Name: GREAT
Date: 4/5/2004 1:46:12 PM
Comment:
GREAT


Title: re: IE 5.0 Error
Name: Michael Ash
Date: 1/16/2004 11:56:30 AM
Comment:
You could also try updating to the latest version of the Window scripting enigine http://msdn.microsoft.com/library/default.asp?url=/nhp/default.asp?contentid=28001169 if you don't have the latest version and see if that helps


Title: re: IE 5.0 Error
Name: Michael Ash
Date: 1/16/2004 10:54:57 AM
Comment:
I looked at that link but I don't see how that would apply since the regex doesn't meet that critera. This is only one repetition factor in the entire expression \d{2}. You can try and replace it with \d\d Maybe IE5's regex engine doesn't support {n} repetitions. Anyone know?


Title: re:Year field should accept 4 digits only
Name: Michael Ash
Date: 1/16/2004 10:42:28 AM
Comment:
remove the ? after both occurances of (?:1[6-9]|[2-9]\d)?


Title: IE 5.0 Error
Name: Brian
Date: 1/16/2004 9:28:28 AM
Comment:
I'm getting an error using IE 5.0 using this expression. Error: Unexpected quantifier Here's an article on msdn about this error: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jserrunexpectedquantifier.asp


Title: Year field should accept 4 digits only
Name: Manohar
Date: 1/16/2004 1:29:03 AM
Comment:
Pls let me know, where to change the below regex to accept only 4 digit years. I am waiting for u r reply eagerly.


Title: cont...
Name: Michael Ash
Date: 1/16/2004 12:51:45 AM
Comment:
assumed. Doesn't look like you don't need to change the end date.


Title: re: How to change starting and ending years
Name: Michael Ash
Date: 1/16/2004 12:48:29 AM
Comment:
It might be easier to check the year in your code Starting on such an odd year (1753) makes modifying the year checks tricky because you have to 1) check the year in two places. Leap and non-leap years 2a) starting in the middle of the century and 2b) starting a 1/3 into the decade will require two special checks for 1753-1799 for both year checks However instead of changing the original regex I appended a negative look-ahead for the years 1600-1752 (?!(?:16\d\d|(?:17(?:[1-4]\d|5[012])))) actual The following regex should work but you should give it some more testing. ^(?!(?:16\d\d|(?:17(?:[1-4]\d|5[012]))))(?:(?:(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\/|-|\.)(?:0?2\1(?:29))$)|(?:(?:1[6-9]|[2-9]\d)?\d{2})(\/|-|\.)(?:(?:(?:0?[13578]|1[02])\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\2(?:0?[1-9]|1\d|2[0-8])))$ of course the two digit years would still take 00-99 since no century is ass


Title: How to change starting and ending years
Name: Manohar
Date: 1/13/2004 10:08:12 AM
Comment:
yes my starting year should be 1753 onwards, where i have to change pls give me reply immediately


Title: re: How to change starting and ending years
Name: Michael Ash
Date: 1/13/2004 10:03:34 AM
Comment:
That would depend on what you wanted to change the starting and ending years to. I'm guessing you want a narrower range?


Title: How to change starting and ending years
Name: Manohar
Date: 1/13/2004 9:19:18 AM
Comment:
how to change the starting year from 1600 some other and the same for ending year.


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