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
^(\d{2}((0[1-9]|1[012])(0[1-9]|1\d|2[0-8])|(0[13456789]|1[012])(29|30)|(0[13578]|1[02])31)|([02468][048]|[13579][26])0229)$
Description
yyMMdd with leap years. Minimized expression. As we have only 2 numbers for the years, dates 1600, 2000, etc are still validated.
Matches
001231 | 000229 | 040229
Non-Matches
003112 | 000431 | 010229
Author Rating: The rating for this expression. Dany Lauener
Title Test Details Pattern Title
Expression
^(?=\d)(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:\x20|$))|(?:2[0-8]|1\d|0?[1-9]))([-./])(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9]\d)?\d\d(?:(?=\x20\d)\x20|$))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$
Description
DateTime Validator. This RE validates both dates and/or times patterns. Days in Feb. are also validated for Leap years. Dates: in dd/mm/yyyy or d/m/yy format between 1/1/1600 - 31/12/9999. Leading zeroes are optional. Date separators can be either matching dashes(-), slashes(/) or periods(.) Times: in the hh:MM:ss AM/PM 12 hour format (12:00 AM - 11:59:59 PM) or hh:MM:ss military time format (00:00:00 - 23:59:59). The 12 hour time format: 1) may have a leading zero for the hour. 2) Minutes and seconds are optional for the 12 hour format 3) AM or PM is required and case sensitive. Military time 1) must have a leading zero for all hours less than 10. 2) Minutes are manditory. 3) seconds are optional. Datetimes: combination of the above formats. A date first then a time separated by a space. ex) dd/mm/yyyy hh:MM:ss This RE is an variation of one of my other Datetime (mm/dd/yyyy) validator already in this library http://www.regexlib.com/REDetails.aspx?regexp_id=369, so the same rules for leap year apply. All 4 digit year and all two digit years except 00, which might not be a leap year.
Matches
31/12/2003 11:59:59 PM | 29-2-2004 | 01:45:02
Non-Matches
12/31/2003 | 29.02.2005 | 13:30 PM
Author Rating: The rating for this expression. Michael Ash
Title Test Details Pattern Title
Expression
^([0-1]?[0-9]|[2][0-3]):([0-5][0-9])$
Description
Accepts data of time in format h:mm and hh:mm ^([0-1]?[0-9]|[2][0-3]):([0-5][0-9])$ in php [0-23]:[0-59]{2} (posix)
Matches
0:00 | 23:00 | 00:59
Non-Matches
0:0 | 24:00 | 00:60
Author Rating: The rating for this expression. Morten Henriksen
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])|([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
^[0,1]?\d{1}\/(([0-2]?\d{1})|([3][0,1]{1}))\/(([1]{1}[9]{1}[9]{1}\d{1})|([2-9]{1}\d{3}))$
Description
This expression checks the validity of a date (US, but it is easily editable for other format's). Year's 1990-9999, Month's 1 or 01 to 12, Day's 1 or 01 to 31. Still needs to have individual months added (i.e., Feb's 28 days), and some how to check for leap year...the months issue should not be to hard, but the leap year seems like a real chore. Please let me know if you have any suggestions for leap year.
Matches
01/01/1990 | 12/12/9999 | 3/28/2001
Non-Matches
3-8-01 | 13/32/1001 | 03/32/1989
Author Rating: The rating for this expression. Scott Watermasysk
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?[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]?[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 DateTime M/d/y hh:mm:ss
Expression
^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$
Description
DateTime Validator.
Matches
12/25/2003 | 08:03:31 | 02/29/2004 12 AM
Non-Matches
02/29/2003 1:34 PM | 13:23 PM | 24:00:00
Author Rating: The rating for this expression. Michael Ash
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)([/])([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 MM/YYYY MONTH/YEAR
Expression
^((0[1-9])|(1[0-2]))\/(\d{4})$
Description
This regular expressions matches dates in the format MM/YYYY where MM can be 01 to 12 and YYYY is always 4 digits long.
Matches
12/2002 | 11/1900 | 02/1977
Non-Matches
1/1977 | 00/000 | 15/2002
Author Rating: The rating for this expression. Jony Ferreira
Title Test Details Pattern Title
Expression
(((0[123456789]|10|11|12)([/])(([1][9][0-9][0-9])|([2][0-9][0-9][0-9]))))
Description
This is an new data Validation to MM/YYYY from 1900 to 2999 this is an validation expression to Client From MOnth/Year.
Matches
01/1900 | 10/1990 | 12/2999
Non-Matches
1/1900 | 12/1899 | 01/3000
Author Rating: The rating for this expression. Felipe Albacete
Title Test Details Pattern Title
Expression
((([0][1-9]|[12][\d])|[3][01])[-/]([0][13578]|[1][02])[-/][1-9]\d\d\d)|((([0][1-9]|[12][\d])|[3][0])[-/]([0][13456789]|[1][012])[-/][1-9]\d\d\d)|(([0][1-9]|[12][\d])[-/][0][2][-/][1-9]\d([02468][048]|[13579][26]))|(([0][1-9]|[12][0-8])[-/][0][2][-/][1-9]\d\d\d)
Description
Date validation in the dd/mm/yyyy format for years 1000+ (i.e 999 or 0999 not matching) and taking february leap years into account.
Matches
12/12/2003 | 29-02-2004 | 31-03-1980
Non-Matches
29/02/2003 | 31-04-2002 | 10-10-0999
Author Rating: The rating for this expression. Uris Virott
Title Test Details Pattern Title
Expression
^([0]?[1-9]|[1|2][0-9]|[3][0|1])[./-]([0]?[1-9]|[1][0-2])[./-]([0-9]{4}|[0-9]{2})$
Description
Validate brazilian date formats: dd/mm/yyyy or d/m/yy or d.m.yyyy with separators: . - / Valid dates only! d (1-31)/ m (1-12)/ y (0..) (rizzipereira.com.br) For American date format: http://www.regexlib.com/REDetails.aspx?regexp_id=932
Matches
10/03/1979 | 1-1-02 | 01.1.2003
Non-Matches
10/03/197 | 09--02--2004 | 01 02 03
Author Rating: The rating for this expression. Diego dos Santos
Title Test Details Pattern Title
Expression
(0?[1-9]|[12][0-9]|3[01])[/ -](0?[1-9]|1[12])[/ -](19[0-9]{2}|[2][0-9][0-9]{2})
Description
Essa express&#227;o &#233; uma valida&#231;&#227;o de data simplicada onde n&#227;o aceita datas com ano inferior a 1900. Interessante pra valida&#231;&#227;o de data de idade, data atual, etc
Matches
25/11/1979 | 5-12-2004 | 5 2 1901
Non-Matches
25/11/1899 | 9-12-1700 | 25111979
Author Rating: The rating for this expression. Fabiano Santiago
Title Test Details A.D. Calendar dates
Expression
(?#Calandar from January 1st 1 A.D to December 31, 9999 )(?# in yyyy-mm-dd format )(?!(?:1582\D10\D(?:0?[5-9]|1[0-4]))|(?#Missing days from 1582 )(?:1752\D0?9\D(?:0?[3-9]|1[0-3]))(?#or Missing days from 1752 )(?# both sets of missing days should not be in the same calendar so remove one or the other))(?n:^(?=\d)(?# the character at the beginning a the string must be a digit )((?'year'\d{4})(?'sep'[-./])(?'month'0?[1-9]|1[012])\k'sep'(?'day'(?<!(?:0?[469]|11).)31|(?<!0?2.)30|2[0-8]|1\d|0?[1-9]|(?# if feb 29th check for valid leap year )(?:(?<=(?!(?#exclude these years from leap year pattern ) 000[04](?#No year 0 and no leap year in year 4 )|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00)(?# centurial years > 1500 not evenly divisible by 400 are not leap year))(?:(?:\d\d)(?# century)(?:[02468][048]|[13579][26])(?#leap years))\k'sep'(?:0?2)\k'sep')|(?# else if not Feb 29 )(?<!\k'sep'(?:0?2)\k'sep')(?# and day not Feb 30 or 31 ))29)(?(?=\x20\d)\x20|$))?(?# if there is a space followed by a digit check for time )(?<time>((?# 12 hour format )(0?[1-9]|1[012])(?# hours )(:[0-5]\d){0,2}(?# optional minutes and seconds )(?i:\x20[AP]M)(?# required AM or PM ))|(?# 24 hour format )([01]\d|2[0-3])(?#hours )(:[0-5]\d){1,2})(?#required minutes optional seconds )?$)
Description
yyyy-mm-dd Datetime for AD, with leap year. See http://blogs.regexadvice.com/mash/archive/2004/04/23/1021.aspx for details on similar regexs
Matches
0001-06-16 12:00:01 AM | 2004/2/29 | 3:30 PM
Non-Matches
9999/99/99 | 24:00:00 | 2003-02-29
Author Rating: The rating for this expression. Michael Ash
Title Test Details dd MMM yyyy Date
Expression
^((31(?!\ (Feb(ruary)?|Apr(il)?|June?|(Sep(?=\b|t)t?|Nov)(ember)?)))|((30|29)(?!\ Feb(ruary)?))|(29(?=\ Feb(ruary)?\ (((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(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\b|t)t?|Nov|Dec)(ember)?)\ ((1[6-9]|[2-9]\d)\d{2})$
Description
This RE validates dates in the dd MMM yyyy format. Spaces separate the values.
Matches
31 January 2003 | 29 March 2004 | 29 Feb 2008
Non-Matches
Jan 1 2003 | 31 Sept 2003 | 29 February 2003
Author Rating: The rating for this expression. Michael Ash
Change page:   |    Displaying page 1 of 7 pages; Items 1 to 20

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