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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
(?=\d)^(?:(?!(?:10\D(?:0?[5-9]|1[0-4])\D(?:1582))|(?:0?9\D(?:0?[3-9]|1[0-3])\D(?:1752)))((?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)(?!-31)(?!\.31)|(?:0?2(?=.?(?:(?:29.(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:(?:\d\d)(?:[02468][048]|[13579][26])(?!\x20BC))|(?:00(?:42|3[0369]|2[147]|1[258]|09)\x20BC))))))|(?:0?2(?=.(?:(?:\d\D)|(?:[01]\d)|(?:2[0-8])))))([-.\/])(0?[1-9]|[12]\d|3[01])\2(?!0000)((?=(?:00(?:4[0-5]|[0-3]?\d)\x20BC)|(?:\d{4}(?!\x20BC)))\d{4}(?:\x20BC)?)(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]\d|2[0-3])(?::[0-5]\d){1,2})?$
Description
mm/dd/yyyy hh:MM:ss Datetime for all AD years, including leap years. Javascript safe version of http://regexlib.com/REDetails.aspx?regexp_id=644. Please see that regex for details of what is being checked
Matches
11/24/0004 11:59 PM | 2.29.2008 | 02:50:10
Non-Matches
12/33/1020 | 2/29/2005 | 13:00 AM
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: Appreciation
Name: Keith
Date: 8/5/2021 12:22:03 PM
Comment:
This is very useful! Thank you for making available :)


Title: Developer
Name: Naveen
Date: 2/14/2010 3:22:35 AM
Comment:
Its amazing and works a charm.


Title: Developer
Name: Naveen
Date: 2/14/2010 3:22:16 AM
Comment:
Its amazing and works a charm.


Title: RegEX for web address
Name: Amrita
Date: 1/23/2009 7:32:23 AM
Comment:
I currently have regex that accepts web addresses of the format wwwwww.yahoo.com. how do i catch this using regex?


Title: RegEX for web address
Name: Amrita
Date: 1/23/2009 5:50:25 AM
Comment:
I currently have regex that accepts web addresses of the format wwwwww.yahoo.com. how do i catch this using regex?


Title: RegEX for web address
Name: Amrita
Date: 1/23/2009 5:47:58 AM
Comment:
I currently have regex that accepts web addresses of the format wwwwww.yahoo.com. how do i catch this using regex?


Title: RegEX for web address
Name: Amrita
Date: 1/23/2009 5:46:51 AM
Comment:
I currently have regex that accepts web addresses of the format wwwwww.yahoo.com. how do i catch this using regex?


Title: Limiting the century range
Name: Sivaram
Date: 9/7/2007 2:36:59 PM
Comment:
Hi, This is an excellent pattern to validate the date/ date & time. I am fairly new to Regex. Can you please provide the above pattern limiting the century to 19th and 20th (say year between 1900 and 2099).


Title: Limiting the century range
Name: Sivaram
Date: 9/7/2007 2:36:29 PM
Comment:
Hi, This is an excellent pattern to validate the date/ date & time. I am fairly new to Regex. Can you please provide the above pattern limiting the century to 19th and 20th (say year between 1900 and 2099).


Title: Limiting the year range.
Name: Riddle
Date: 6/12/2007 7:13:41 AM
Comment:
Is there any way to limit the year between 1753 and 9999?


Title: Limiting the year range.
Name: Riddle
Date: 6/12/2007 7:13:11 AM
Comment:
Is there any way to limit the year between 1753 and 9999?


Title: Required Another Format
Name: Ravi Kumar GVR
Date: 11/23/2005 2:13:18 AM
Comment:
Hi Michael Its great work done by you to validate date using a Regular Expression. I have gone through your expresions, but i need the same DATE validation in MMM-DD-YYYY e.g. Feb-29-2008 this format including leap year validation for February 29 also. Please let me know if this format of validation is available in your archive at this regexlib.com. Please mail me to [email protected] Yours Ravi Kumar GVR


Title: Simpler
Name: Joshua Lunsford
Date: 11/9/2005 12:12:42 PM
Comment:
is there a way to shorten this expression to only match 'MM/dd/yyyy'? I noticed it matched 'MM-dd-yyyy', that wouldn't be good for me either. I'm new to regex, I have O'Reilly's regex books on order... this expression is close to what i need, I'm not sure what to edit out of it. Could someone email? [email protected], thanks


Title: Re: Is this checking for two--digit years?
Name: Michael Ash
Date: 9/7/2005 10:12:40 AM
Comment:
Sorry, that should read... you can't properly validate leap years with only two digit years.


Title: Re: Is this checking for two--digit years?
Name: Michael Ash
Date: 9/7/2005 2:01:46 AM
Comment:
No, it isn't because you can't leap years properly using two digit years. Please see http://regexadvice.com/blogs/mash/archive/2004/04/23/304.aspx if you want more info on this.


Title: Is this checking for two--digit years?
Name: Bryan Wilhite
Date: 9/6/2005 8:01:48 PM
Comment:
I can get matches for two-digit years when I modify this for JavaScript. Is this comment useful?


Title: re:javascript
Name: Sam
Date: 8/12/2005 11:17:35 AM
Comment:
Wow, you're awesome.. Thanks very much, the script works great, the regex works perfect... I see I really need to set aside more time for learning more about this.. I had no idea that it was that in-depth and inclusive... Thanks again, especially for the quick response. Sam


Title: Re: Javascript
Name: Michael Ash
Date: 8/12/2005 2:35:36 AM
Comment:
Sorry there was an unescaped / in the pattern. It should be fixed now. The part of the pattern (?!/31) should be (?!\/31)


Title: Javascript
Name: Sam
Date: 8/11/2005 5:42:17 PM
Comment:
your blog listed this as the one for using with javascript, but I get errors with it on this line : var oRegExpNewDate = /(?=\d)^(?:(?!(?:10\D(?:0?[5-9]|1[0-4])\D(?:1582))|(?:0?9\D(?:0?[3-9]|1[0-3])\D(?:1752)))((?:0?[13578]|1[02])|(?:0?[469]|11)(?!/31)(?!-31)(?!\.31)|(?:0?2(?=.?(?:(?:29.(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:(?:\d\d)(?:[02468][048]|[13579][26])(?!\x20BC))|(?:00(?:42|3[0369]|2[147]|1[258]|09)\x20BC))))))|(?:0?2(?=.(?:(?:\d\D)|(?:[01]\d)|(?:2[0-8])))))([-.\/])(0?[1-9]|[12]\d|3[01])\2(?!0000)((?=(?:00(?:4[0-5]|[0-3]?\d)\x20BC)|(?:\d{4}(?!\x20BC)))\d{4}(?:\x20BC)?)(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]\d|2[0-3])(?::[0-5]\d){1,2})?$/; I've tried it with and without the starting and ending /. I get this error: Error: Expected ')' in regular expression. I copied the code from the test page.. Any ideas? Thanks


Title: Re: allowing only / as separator
Name: Michael Ash
Date: 3/2/2005 10:41:29 AM
Comment:
Replace [-.\/] with just \/


Title: allowing only / as separator
Name: Deepills
Date: 3/2/2005 8:41:31 AM
Comment:
HI, Cud u tell me how to allow only / as separator?Like it shud accept 02/12/2005, but not02.12.2005 or 02-12-2005


Title: Stepping back
Name: Michael Ash
Date: 7/21/2004 4:44:35 PM
Comment:
Modified to include Julian dates back to 45 BC.


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