134 regular expressions found in this category!
Displaying page
of
pages;
Items to
| Title |
Test
Details
Pattern Title
|
| Expression |
^((((19|20)(([02468][048])|([13579][26]))-02-29))|((20[0-9][0-9])|(19[0-9][0-9]))-((((0[1-9])|(1[0-2]))-((0[1-9])|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))))$ |
| Description |
Based on some of the other patterns on RegExpLib. This is the ISO way of writing dates. |
| Matches |
2002-01-31 | 1997-04-30 | 2004-01-01 |
| Non-Matches |
2002-01-32 | 2003-02-29 | 04-01-01 |
| Author |
Rating:
Knut Hamang
|
| Title |
Test
Details
dd/mm/yyyy hh:MM:ss Datetime
|
| Expression |
(?n:^(?=\d)((?<day>31(?!(.0?[2469]|11))|30(?!.0?2)|29(?(.0?2)(?=.{3,4}(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])(?<sep>[/.-])(?<month>0?[1-9]|1[012])\2(?<year>(1[6-9]|[2-9]\d)\d{2})(?:(?=\x20\d)\x20|$))?(?<time>((0?[1-9]|1[012])(:[0-5]\d){0,2}(?i:\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$) |
| Description |
DD/MM/YYYY format New DateTime Regex. Rebuilt better than before, better, stronger, faster. This regex will validate a date, time or a datetime. It will also capture the date fields and the time. Dates are in the DD/MM/YYYY 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(/). Year range 1600-9999 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. Datetime is the above date and time formats separated by a space, with the date first (DD/MM/YYYY HH:mm:SS) !IMPORTANT NOTE: your regex engine must support lookaheads and named groups to use this expression |
| Matches |
31/12/2003 | 29/2/2004 4:50 PM | 23:59:59 |
| Non-Matches |
12/31/2003 | 29/2/2003 | 4:00 |
| Author |
Rating:
Michael Ash
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^(((((0[13578])|([13578])|(1[02]))[\-\/\s]?((0[1-9])|([1-9])|([1-2][0-9])|(3[01])))|((([469])|(11))[\-\/\s]?((0[1-9])|([1-9])|([1-2][0-9])|(30)))|((02|2)[\-\/\s]?((0[1-9])|([1-9])|([1-2][0-9]))))[\-\/\s]?\d{4})(\s(((0[1-9])|([1-9])|(1[0-2]))\:([0-5][0-9])((\s)|(\:([0-5][0-9])\s))([AM|PM|am|pm]{2,2})))?$ |
| Description |
Following expression can be used to validate a datetime column from SQL Server. This expression is an enhanced version of Scott Watermasysk's date/time submission. It now accepts leading zeros in months, days, and hours. In addition, this expression properly handles the 11th hour. Watermasysk's would take the 10th and 12th hour but not the 11th. This regex has been tweaked to do so. Does not handle the February 29th problem on non-leap years yet. Will learn a little more about RegEx and do so in later submission.
|
| Matches |
11/30/2003 10:12:24 am | 2/29/2003 08:14:56 pm | 5/22/2003 |
| Non-Matches |
11/31/2003 10:12:24 am | 2/30/2003 08:14:56 pm | 5/22/2003 14:15 |
| Author |
Rating:
David Darling
|
| 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:
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:
martin devos
|
| 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:
Diego dos Santos
|
| 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}))|((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])[\.\-\/]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)|00)))$ |
| Description |
DD.MM.YY or DD.MM.YYYY
separator could be on choice '.' '/' or '-'
leap years compatible, 00 is treated as year 2000. |
| Matches |
29.2.04 | 29/02-2004 | 3.4.05 |
| Non-Matches |
29.2.03 | 2902.2004 | 12.31.1975 |
| Author |
Rating:
Dany Lauener
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[2][0]\d{2})$|^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[2][0]\d{2}\s([0-1]\d|[2][0-3])\:[0-5]\d\:[0-5]\d)$ |
| Description |
Correct French DateTime(DD/MM/YYYY OR DD/MM/YYYY HH:MM:SS) |
| Matches |
12/01/2002 | 12/01/2002 12:32:10 |
| Non-Matches |
32/12/2002 | 12/13/2001 | 12/02/06 |
| Author |
Rating:
Samir AZZA
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^((([0]?[1-9]|1[0-2])(:|\.)[0-5][0-9]((:|\.)[0-5][0-9])?( )?(AM|am|aM|Am|PM|pm|pM|Pm))|(([0]?[0-9]|1[0-9]|2[0-3])(:|\.)[0-5][0-9]((:|\.)[0-5][0-9])?))$ |
| Description |
Matches times seperated by either : or . will match a 24 hour time, or a 12 hour time with AM or PM specified. Allows 0-59 minutes, and 0-59 seconds. Seconds are not required. |
| Matches |
1:01 AM | 23:52:01 | 03.24.36 AM |
| Non-Matches |
19:31 AM | 9:9 PM | 25:60:61 |
| Author |
Rating:
Steve Valaitis
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(^([0-9]|[0-1][0-9]|[2][0-3]):([0-5][0-9])$)|(^([0-9]|[1][0-9]|[2][0-3])$) |
| Description |
Matches a string if it is a valid time in the format of HH:MM / H:MM / HH / H |
| Matches |
10:35 | 9:20 | 23 |
| Non-Matches |
24:00 | 20 PM | 20:15 PM |
| Author |
Rating:
Nacho Varas
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(^((((0[1-9])|([1-2][0-9])|(3[0-1]))|([1-9]))\x2F(((0[1-9])|(1[0-2]))|([1-9]))\x2F(([0-9]{2})|(((19)|([2]([0]{1})))([0-9]{2}))))$) |
| Description |
dd/mm/yy
Check dates between 1/1/1900 - 31/12/2099 |
| Matches |
31/12/2099 | 1/1/1900 | 10/12/2003 |
| Non-Matches |
05/11/3000 | 11/13/2003 | 32/04/2030 |
| Author |
Rating:
Carlos R. L. Rodrigues
|
| Title |
Test
Details
Pattern Title
|
| Expression |
[-+]((0[0-9]|1[0-3]):([03]0|45)|14:00) |
| Description |
This matches timezone offsets. Also matches non-hour offsets like India (+05:30) and Nepal (+5:45}. See for more timezone information: http://en.wikipedia.org/wiki/Time_zone |
| Matches |
+00:00 | -05:00 | +13:45 |
| Non-Matches |
+14:30 | +01:14 | -09:55 |
| Author |
Rating:
Robert van der Boon
|
| 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:
Neil Walls
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^[0-9]{4}-(((0[13578]|(10|12))-(0[1-9]|[1-2][0-9]|3[0-1]))|(02-(0[1-9]|[1-2][0-9]))|((0[469]|11)-(0[1-9]|[1-2][0-9]|30)))$ |
| Description |
Matches the date format "YYYY-mm-dd" and also validates month and number of days in a month. All leap year dates "YYYY-02-29" passes trough. Could easily be changed to another format. |
| Matches |
2004-04-30 | 2004-02-29 |
| Non-Matches |
2004-04-31 | 2004-02-30 |
| Author |
Rating:
Johan Södercrantz
|
| 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:
Scott Watermasysk
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^(([0]?[1-9]|1[0-2])/([0-2]?[0-9]|3[0-1])/[1-2]\d{3})? ?((([0-1]?\d)|(2[0-3])):[0-5]\d)?(:[0-5]\d)? ?(AM|am|PM|pm)?$ |
| Description |
Matches variations on date/time/AM-PM. Must have 4 digit year, but everything else is open. Restrictions are: 4 digit year, months 1-12, hours 1-23, minutes and seconds 1-59, any case of AM and PM. If this don't woik, I wrote it, lemmy know. |
| Matches |
12/30/2002 | 12/30/2002 9:35 pm | 12/30/2002 19:35:02 |
| Non-Matches |
18/22/2003 | 8/12/99 | 8/22/2003 25:00 |
| Author |
Rating:
Michael Gaertner
|
| 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:
Dany Lauener
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^((0[1-9])|(1[0-2]))$ |
| Description |
Matches month, requires that months 1-9 have a leading 0 |
| Matches |
01 | 02 | 12 |
| Non-Matches |
1 | 2 | 13 |
| Author |
Rating:
Tim Macrina
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^((((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9]))))[\-\/\s]?\d{2}(([02468][048])|([13579][26])))|(((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))[\-\/\s]?\d{2}(([02468][1235679])|([13579][01345789]))))(\s(((0?[1-9])|(1[0-2]))\:([0-5][0-9])((\s)|(\:([0-5][0-9])\s))([AM|PM|am|pm]{2,2})))?$ |
| Description |
This regex will match SQL Server datetime values, allowing date only, allowing zero padded digits in month, day and hour, and will match leap years from 1901 up until 2099. |
| Matches |
2/29/2004 | 04/01/2003 10:01:23 am | 03-20-1999 |
| Non-Matches |
2/29/2003 | 13/30/2001 10:05:00 pm | 12/32/2003 |
| Author |
Rating:
Sung Lee
|
| 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:
Dany Lauener
|
Displaying page
of
pages;
Items to