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

Please support RegExLib Sponsors

Sponsors

Browse Expressions by Category

134 regular expressions found in this category!

Expressions in category: Dates and Times

Change page:   |    Displaying page 1 of 7 pages; Items 1 to 20
Title Test Details Pattern Title
Expression
^((((0[13578])|([13578])|(1[02]))[\/](([1-9])|([0-2][0-9])|(3[01])))|(((0[469])|([469])|(11))[\/](([1-9])|([0-2][0-9])|(30)))|((2|02)[\/](([1-9])|([0-2][0-9]))))[\/]\d{4}$|^\d{4}$
Description
The following validates dates with and without leading zeros in the following formats: MM/DD/YYYY and it also takes YYYY (this can easily be removed). All months are validated for the correct number of days for that particular month except for February which can be set to 29 days. date day month year
Matches
01/01/2001 | 1/01/2001 | 2002
Non-Matches
2/30/2002 | 13/23/2002 | 12345
Author Rating: The rating for this expression. Matt Adams
Title Test Details Pattern Title
Expression
^([01]\d|2[0123])([0-5]\d){2}$
Description
HHmmss without any separators. Hours in 24h format.
Matches
235959 | 000000 | 012345
Non-Matches
240000 | 23:59:59 | 236060
Author Rating: The rating for this expression. Dany Lauener
Title Test Details Pattern Title
Expression
^((0?[13578]|10|12)(-|\/)(([1-9])|(0[1-9])|([12])([0-9]?)|(3[01]?))(-|\/)((19)([2-9])(\d{1})|(20)([01])(\d{1})|([8901])(\d{1}))|(0?[2469]|11)(-|\/)(([1-9])|(0[1-9])|([12])([0-9]?)|(3[0]?))(-|\/)((19)([2-9])(\d{1})|(20)([01])(\d{1})|([8901])(\d{1})))$
Description
improved date validation M/D/YY or M/D/YYYY or MM/DD/YYYY or MM/DD/YY: 1/1/1920 through 12/31/2019; Feb 29 and 30 always allowed, deal with it
Matches
1/2/03 | 02/30/1999 | 3/04/00
Non-Matches
3/4/2020 | 3/4/1919 | 4/31/2000
Author Rating: The rating for this expression. Brad Williams
Title Test Details Pattern Title
Expression
^((31(?! (FEB|APR|JUN|SEP|NOV)))|((30|29)(?! FEB))|(29(?= FEB (((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|FEB|MAR|MAY|APR|JUL|JUN|AUG|OCT|SEP|NOV|DEC)-((1[6-9]|[2-9]\d)\d{2})$
Description
Mathces in format DD-MON-YYYY (hyphen between results). Validates for leap years. Ensures month is in uppercase.
Matches
9-MAY-1981 | 29-FEB-2004 | 25-DEC-1999
Non-Matches
09 MAY 1981 | 06 Jul 2003
Author Rating: The rating for this expression. Rohan Pathare
Title Test Details Pattern Title
Expression
^(((((((0?[13578])|(1[02]))[\.\-/]?((0?[1-9])|([12]\d)|(3[01])))|(((0?[469])|(11))[\.\-/]?((0?[1-9])|([12]\d)|(30)))|((0?2)[\.\-/]?((0?[1-9])|(1\d)|(2[0-8]))))[\.\-/]?(((19)|(20))?([\d][\d]))))|((0?2)[\.\-/]?(29)[\.\-/]?(((19)|(20))?(([02468][048])|([13579][26])))))$
Description
Simple American date format mm-dd-yyyy or mm-dd-yy, no time. Date range is 1900 --> 2099. Is enough for my purposes. Incorectly validates 02-29-1900. I created this to validate dates on a web form where the likely range will be 2000-->2020. Seperators can be '.','/' or '-' Anyone know the rules for operator precedence for regex syntax?
Matches
02-29-2004 | 1/31/1997 | 1-2-03
Non-Matches
02-29-2003 | 04-31-2003 | 31-03-05
Author Rating: The rating for this expression. Neil Walls
Title Test Details Pattern Title
Expression
^(((0[1-9]|1[012])/(0[1-9]|1\d|2[0-8])|(0[13456789]|1[012])/(29|30)|(0[13578]|1[02])/31)/[2-9]\d{3}|02/29/(([2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00)))$
Description
MM/dd/yyyy with 100% leap year validation starting from year 2000. If this one doesn't fit your needs, just tell me. Sorry for starting "only" from year 2000, this is so simple to change this, please ask if needed. Enjoy
Matches
02/29/2000 | 02/29/2004 | 12/31/2001
Non-Matches
02/29/2100 | 02/29/2001 | 1/1/2001
Author Rating: The rating for this expression. Dany Lauener
Title Test Details Pattern Title
Expression
^(?=\d)(?:(?!(?:(?:0?[5-9]|1[0-4])(?:\.|-|\/)10(?:\.|-|\/)(?:1582))|(?:(?:0?[3-9]|1[0-3])(?:\.|-|\/)0?9(?:\.|-|\/)(?:1752)))(31(?!(?:\.|-|\/)(?:0?[2469]|11))|30(?!(?:\.|-|\/)0?2)|(?:29(?:(?!(?:\.|-|\/)0?2(?:\.|-|\/))|(?=\D0?2\D(?:(?!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))))))|2[0-8]|1\d|0?[1-9])([-.\/])(1[012]|(?:0?[1-9]))\2((?=(?:00(?:4[0-5]|[0-3]?\d)\x20BC)|(?:\d{4}(?:$|(?=\x20\d)\x20)))\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
dd/mm/yyyy hh:MM:ss Datetime for all AD years, including leap years. Javascript safe version of http://regexlib.com/REDetails.aspx?regexp_id=691. Please see that regex for details of what is being checked
Matches
31.12.6008 | 5:30 AM | 30-04-1066
Non-Matches
00/00/0000 | 99:99:99 | 29/02/2005
Author Rating: The rating for this expression. Michael Ash
Title Test Details yyyy/mm/dd hhMMss Date
Expression
^(?ni:(?=\d)((?'year'((1[6-9])|([2-9]\d))\d\d)(?'sep'[/.-])(?'month'0?[1-9]|1[012])\2(?'day'((?<!(\2((0?[2469])|11)\2))31)|(?<!\2(0?2)\2)(29|30)|((?<=((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(16|[2468][048]|[3579][26])00)\2\3\2)29)|((0?[1-9])|(1\d)|(2[0-8])))(?:(?=\x20\d)\x20|$))?((?<time>((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2}))?)$
Description
YYYY/MM/DD hh:mm:ss format DateTime Regex. This regex will validate a date, time or a datetime. It will also capture the date fields and the time. Dates are in the YYYY/MM/DD format and validated for months, number of days in a month and leap years (29/2) Date field can be separated by matched periods(.), dashes(-) or forward slashes(/) Time is either 12 hour AM/PM format (hh:mm:ss AM), where minutes and seconds are optional. AM or PM required. or 24 hour military format (hh:mm:ss), from 00:00:00 to 23:59:59, where hours and minutes fields are required, including leading 0 for hours less than 10. Please refer to http://blogs.regexadvice.com/mash/archive/2004/04/23/1021.aspx for additional info Datetime is the above date and time formats separated by a space, with the date first (YYYY/MM/DD hh:mm:ss) !IMPORTANT NOTE: your regex engine must support lookbehinds and named groups to use this expression
Matches
12:30 PM | 2004-02-29 | 2004/3/31 02:31:35 AM
Non-Matches
2:00 | 2200.2.29 | 0000/00/00 00:00:00 AM
Author Rating: The rating for this expression. Michael Ash
Title Test Details Pattern Title
Expression
(((0[1-9]|[12][0-9]|3[01])([/])(0[13578]|10|12)([/])(\d{4}))|(([0][1-9]|[12][0-9]|30)([/])(0[469]|11)([/])(\d{4}))|((0[1-9]|1[0-9]|2[0-8])([/])(02)([/])(\d{4}))|((29)(\.|-|\/)(02)([/])([02468][048]00))|((29)([/])(02)([/])([13579][26]00))|((29)([/])(02)([/])([0-9][0-9][0][48]))|((29)([/])(02)([/])([0-9][0-9][2468][048]))|((29)([/])(02)([/])([0-9][0-9][13579][26])))
Description
Date in DD/MM/YYYY format. Fecha en formato DD/MM/AAAA.
Matches
28/12/2003 | 28/02/2003 | 29/02/2000
Non-Matches
28-02-2003 | 30/02/2003 | 28.02.2003
Author Rating: The rating for this expression. Mathews Inga
Title Test Details Pattern Title
Expression
^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?$
Description
Time in 24 hours format with optional seconds
Matches
12:15 | 10:26:59 | 22:01:15
Non-Matches
24:10:25 | 13:2:60
Author Rating: The rating for this expression. Carlos R. L. Rodrigues
Title Test Details Pattern Title
Expression
^((((31\/(0?[13578]|1[02]))|((29|30)\/(0?[1,3-9]|1[0-2])))\/(1[6-9]|[2-9]\d)?\d{2})|(29\/0?2\/(((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])\/((0?[1-9])|(1[0-2]))\/((1[6-9]|[2-9]\d)?\d{2})) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d$
Description
this expression validates a date-time field in European d/m/y h:m:s format. It is a european variation of Michael Ash's date-validation expression in this library. The days are validated for the given month and year. Leap years are validated for all 4 digits years from 1600-9999, and all 2 digits years except 00
Matches
29/02/2004 20:15:27 | 29/2/04 8:9:5 | 31/3/2004 9:20:17
Non-Matches
29/02/2003 20:15:15 | 2/29/04 20:15:15 | 31/3/4 9:20:17
Author Rating: The rating for this expression. martin devos
Title Test Details Pattern Title
Expression
^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[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 1900 to 9999. As usual, many tests have been made. This was requested by a user : http://www.regexlib.com/REDetails.aspx?regexp_id=409
Matches
29/02/2000 | 30/04/2003 | 01/01/2003
Non-Matches
29/02/2001 | 30-04-2003 | 1/1/1899
Author Rating: The rating for this expression. Dany Lauener
Title Test Details Pattern Title
Expression
^((0?[1-9]|[12][1-9]|3[01])\.(0?[13578]|1[02])\.20[0-9]{2}|(0?[1-9]|[12][1-9]|30)\.(0?[13456789]|1[012])\.20[0-9]{2}|(0?[1-9]|1[1-9]|2[0-8])\.(0?[123456789]|1[012])\.20[0-9]{2}|(0?[1-9]|[12][1-9])\.(0?[123456789]|1[012])\.20(00|04|08|12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96))$
Description
Fully functional date validator in format dd.MM.yyyy Works only within range of years 2000-2099 ! It allows leading zeros but does not require them. The last year pattern (enumeration) is not very clever but I will improve it, if needed.
Matches
31.01.2002 | 29.2.2004 | 09.02.2005
Non-Matches
31.11.2002 | 29.2.2002 | 33.06.2000
Author Rating: The rating for this expression. Dalibor Kalna
Title Test Details Pattern Title
Expression
^([2-9]\d{3}((0[1-9]|1[012])(0[1-9]|1\d|2[0-8])|(0[13456789]|1[012])(29|30)|(0[13578]|1[02])31)|(([2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00))0229)$
Description
yyyyMMdd with leap year validation, starting from year 2000 only. The length of the expression is minimized, but still validates all entries. If you want it with years like 1600 or separators, just ask :)
Matches
20000101 | 20051231 | 20040229
Non-Matches
19990101 | 20053112 | 20050229
Author Rating: The rating for this expression. Dany Lauener
Title Test Details Pattern Title
Expression
((\d{2})|(\d))\/((\d{2})|(\d))\/((\d{4})|(\d{2}))
Description
This matches simple dates against 1 or 2 digits for the month, 1 or 2 digit for the day, and either 2 or 4 digits for the year
Matches
4/5/91 | 04/5/1991 | 4/05/89
Non-Matches
4/5/1
Author Rating: The rating for this expression. Andrew Lader
Title Test Details Pattern Title
Expression
^(((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}|\d))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00|[048])))$
Description
This regexp has been posted specialy for &quot;Mike O Shea&quot; as he requested a mono digit year validation. matches DD/MM/Y or DD/MM/YYYY or D/M/Y or DD/M/YYYY Leap years treated. (Italian style with tomato) Years 0-9 equal years 2000 to 2009 for leap years
Matches
1/1/2005 | 29/02/12 | 29/02/2400
Non-Matches
29/2/2005 | 29/02/13 | 29/02/2200
Author Rating: The rating for this expression. Dany Lauener
Title Test Details Pattern Title
Expression
(((0[1-9]|[12][0-9]|3[01])([/])(0[13578]|10|12)([/])([1-2][0,9][0-9][0-9]))|(([0][1-9]|[12][0-9]|30)([/])(0[469]|11)([/])([1-2][0,9][0-9][0-9]))|((0[1-9]|1[0-9]|2[0-8])([/])(02)([/])([1-2][0,9][0-9][0-9]))|((29)(\.|-|\/)(02)([/])([02468][048]00))|((29)([/])(02)([/])([13579][26]00))|((29)([/])(02)([/])([0-9][0-9][0][48]))|((29)([/])(02)([/])([0-9][0-9][2468][048]))|((29)([/])(02)([/])([0-9][0-9][13579][26])))
Description
This is the Brazilian Date Format. DD/MM/YYYY with the right days per month. Dates &gt;=1900 &lt;=2999.
Matches
29/02/2004 | 31/01/1900 | 31/01/2999
Non-Matches
29/02/2003 | 12042004 | 20/04/04
Author Rating: The rating for this expression. Felipe Albacete
Title Test Details Validate 12hour clock
Expression
(?<Time>^(?:0?[1-9]:[0-5]|1(?=[012])\d:[0-5])\d(?:[ap]m)?)
Description
A co-worker needed a regex to validate time. He could only find patterns that match a 24hour clock. I whipped this expression up to validate a 12hour clock. Hope somebody finds it useful.
Matches
12:00am | 01:30pm | 4:59
Non-Matches
15:30 | 4:78am | 00:00
Author Rating: The rating for this expression. Ariel Merrell
Title Test Details Pattern Title
Expression
(?&lt;Day&gt;[1-9]|[0-3][0-9])/(?&lt;Month&gt;[01][012]|[1-9]|0[1-9])/(?&lt;Year&gt;[12]\d{3}|\d{2})
Description
DD/MM/YY D/M/YY DD/MM/YYYY
Matches
15/05/2004 | 15/5/04
Non-Matches
15/45/04
Author Rating: The rating for this expression. yoram o
Title Test Details Pattern Title
Expression
^(((0?[1-9]|1[012])/(0?[1-9]|1\d|2[0-8])|(0?[13456789]|1[012])/(29|30)|(0?[13578]|1[02])/31)/(19|[2-9]\d)\d{2}|0?2/29/((19|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00)))$
Description
MM/dd/yyyy with 100% leap years. Valid since year 1900. MM and DD could have 1 or 2 digits : M/d/yyyy or MM/d/yyyy or M/dd/yyyy This was a request from a user in http://www.regexlib.com/REDetails.aspx?regexp_id=1038
Matches
01/31/1905 | 1/9/1900 | 2/29/1904
Non-Matches
31/01/2005 | 02/29/2005 | 2/29/2005
Author Rating: The rating for this expression. Dany Lauener
Change page:   |    Displaying page 1 of 7 pages; Items 1 to 20

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