134 regular expressions found in this category!
Displaying page
of
pages;
Items to
Title |
Test
Details
Pattern Title
|
Expression |
^([0-1][0-9]|[2][0-3]):([0-5][0-9])$ |
Description |
Matches a string if it is a valid time in the format of HH:MM |
Matches |
02:04 | 16:56 | 23:59 |
Non-Matches |
02:00 PM | PM2:00 | 24:00 |
Author |
Rating:
Koen Hoorelbeke
|
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:
Jony Ferreira
|
Title |
Test
Details
Pattern Title
|
Expression |
^((\d{2}((0[13578]|1[02])(0[1-9]|[12]\d|3[01])|(0[13456789]|1[012])(0[1-9]|[12]\d|30)|02(0[1-9]|1\d|2[0-8])))|([02468][048]|[13579][26])0229)$ |
Description |
Date expression validator with format YYMMDD
Validates leap years.
Of course, as year has only 2 digits, it's not possible to invalidate years like 2100, 2200, 2300, etc as a non-leap years ! |
Matches |
751231 | 000229 | 040229 |
Non-Matches |
750431 | 010229 | 050229 |
Author |
Rating:
Dany Lauener
|
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:
Michael Ash
|
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:
Dany Lauener
|
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[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:
Matt Adams
|
Title |
Test
Details
mm/dd/yyyy hh:MM:ss AM/PM DateTime
|
Expression |
(?n:^(?=\d)((?<month>(0?[13578])|1[02]|(0?[469]|11)(?!.31)|0?2(?(.29)(?=.29.((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(16|[2468][048]|[3579][26])00))|(?!.3[01])))(?<sep>[-./])(?<day>0?[1-9]|[12]\d|3[01])\k<sep>(?<year>(1[6-9]|[2-9]\d)\d{2})(?(?=\x20\d)\x20|$))?(?<time>((0?[1-9]|1[012])(:[0-5]\d){0,2}(?i:\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$) |
Description |
New DateTime Regex. Rebuilt better than before, better, stronger, faster. |
Matches |
1/31/2002 10 AM | 2/29/2004 | 4:15:04 PM |
Non-Matches |
2/29/2003 | 12/32/2003 | 4:00 |
Author |
Rating:
Michael Ash
|
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:
Dany Lauener
|
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
Date With Slashes
|
Expression |
^\d{1,2}\/\d{1,2}\/\d{4}$ |
Description |
This regular expressions matches dates of the form XX/XX/YYYY where XX can be 1 or 2 digits long and YYYY is always 4 digits long. |
Matches |
4/1/2001 | 12/12/2001 | 55/5/3434 |
Non-Matches |
1/1/01 | 12 Jan 01 | 1-1-2001 |
Author |
Rating:
Steven Smith
|
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)))|(((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])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$ |
Description |
Date with leap years. Accepts '.' '-' and '/' as separators
d.m.yy to dd.mm.yyyy (or d.mm.yy, etc)
Ex: dd-mm-yyyy d.mm/yy dd/m.yyyy etc etc
Accept 00 years also. |
Matches |
29.2.2004 | 31121975 | 29/2-00 |
Non-Matches |
29.2.2005 | 32121975 | 29.2/01 |
Author |
Rating:
Dany Lauener
|
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 |
^(((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:
Dany Lauener
|
Title |
Test
Details
Pattern Title
|
Expression |
^\d{4}[\-\/\s]?((((0[13578])|(1[02]))[\-\/\s]?(([0-2][0-9])|(3[01])))|(((0[469])|(11))[\-\/\s]?(([0-2][0-9])|(30)))|(02[\-\/\s]?[0-2][0-9]))$ |
Description |
- validates a yyyy-mm-dd, yyyy mm dd, or yyyy/mm/dd date
- makes sure day is within valid range for the month
- does NOT validate Feb. 29 on a leap year, only that Feb. CAN have 29 days |
Matches |
0001-12-31 | 9999 09 30 | 2002/03/03 |
Non-Matches |
0001\02\30 | 9999.15.01 | 2002/3/3 |
Author |
Rating:
Rex Po
|
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:
Michael Ash
|
Title |
Test
Details
Pattern Title
|
Expression |
^((0[1-9])|(1[0-2]))\/(\d{2})$ |
Description |
Validates MM/YY for rough checking credit card expiration dates. |
Matches |
11/03 | 01/04 |
Non-Matches |
13/03 | 10/2003 |
Author |
Rating:
Kevin Coleman
|
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:
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:
Michael Ash
|
Title |
Test
Details
Pattern Title
|
Expression |
^(((((0[1-9])|(1\d)|(2[0-8]))-((0[1-9])|(1[0-2])))|((31-((0[13578])|(1[02])))|((29|30)-((0[1,3-9])|(1[0-2])))))-((20[0-9][0-9]))|(29-02-20(([02468][048])|([13579][26]))))$ |
Description |
This expression validates a date field in the European DD-MM-YYYY format. Days are validate for the given month and year. |
Matches |
05-01-2002 | 29-02-2004 | 31-12-2002 |
Non-Matches |
1-1-02 | 29-02-2002 | 31-11-2002 |
Author |
Rating:
Jörg Maag
|
Displaying page
of
pages;
Items to