134 regular expressions found in this category!
Displaying page
of
pages;
Items to
Title |
Test
Details
DateTime type format
|
Expression |
(\d{2}|\d{4})(?:\-)?([0]{1}\d{1}|[1]{1}[0-2]{1})(?:\-)?([0-2]{1}\d{1}|[3]{1}[0-1]{1})(?:\s)?([0-1]{1}\d{1}|[2]{1}[0-3]{1})(?::)?([0-5]{1}\d{1})(?::)?([0-5]{1}\d{1}) |
Description |
Will match a date accepted by MySQL datetime type.
Years with 2 or 4 digits from any range.
Months with 2 digits from 00 to 12.
days with 2 digits from 00 to 31.
Hours with 2 digits from 00-23
Minutes with 2 digits from 00 to 59.
Seconds with 2 digits from 00 to 59. |
Matches |
00-00-00 00:00:00 | 0000-00-00 00:00:00 | 09-05-22 08:16:00 | 1970-00-00 00:00:00 | 20090522081600 |
Non-Matches |
2009-13:01 00:00:00 | 2009-12-32 00:00:00 | 2002-12-31 24:00:00 | 2002-12-31 23:60:00 | 02-12-31 23:00:60 |
Author |
Rating:
Not yet rated.
João Batista Neto
|
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:
Not yet rated.
Robert van der Boon
|
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]))|((((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])))))/((19[0-9][0-9]))|(29/02/20(([02468][048])|([13579][26])))|(29/02/19(([02468][048])|([13579][26]))))$ |
Description |
This expression is an improved version of Jörg Maag. It checks a date field in the Australian DD/MM/YYYY format. Besides, it also validates leap year between 1900 and 2099. |
Matches |
29/02/1992 | 29/02/2000 | 29/02/2004 |
Non-Matches |
29/02/1892 | 29/02/2100 | 29/02/3004 |
Author |
Rating:
Not yet rated.
Yik Kheam Tan
|
Title |
Test
Details
Pattern Title
|
Expression |
^([0-1]?\d|2[0-3]):([0-5]\d)$ |
Description |
Time in 24h format; minutes must be two digits; hours may be one or two digits |
Matches |
3:23 | 03:23 | 16:59 |
Non-Matches |
12:2 | 12:76 | 33:12 |
Author |
Rating:
Not yet rated.
de kleine Gerardus
|
Title |
Test
Details
dd/mm/yyyy hhMMss Julian to Gregorian DateTime
|
Expression |
(?#Datetime for Julian and Gregorian Calenders
Matchs dates from 0045 BC to 9999 A.D.
Days and months are 1 or 2 digits
Years are 4 digit with leading zeros if required.
February is validate in all leap years
Leap year rules for Julian and Gregorian calendars http://scienceworld.wolfram.com/astronomy/LeapYear.html
Missing days for 1582 and 1752 are not matched. Though only one set should be applied to a calendar since they are caused by when the calendar was adopted
Missing days http://scienceworld.wolfram.com/astronomy/GregorianCalendar.html
Time can be either 12 or 24 hour format
12 hour format hh:MM:ss AM|PM
minutes and seconds are optional
24 hour format hh:mm:ss
seconds are optional, hours less than ten require leading zero
Datetome format is a date, a space then a time.
)
(?#Calandar from January 1st 45 B.C. to December 31, 1999
in dd/mm/yyyy format)
(?!
(?:(?:0?[5-9]|1[0-4])(?<sep>[-./])10\k<sep>(?:1582))| #Missing days from 1582
(?:(?:0?[3-9]|1[0-3])(?<sep>[-./])0?9\k<sep>(?:1752)) #or Missing days from 1752
(?# both sets of missing days such not be in the same calendar
so remove one or the other)
)
(?n:^(?=\d) # the character at the beginning a the sring must be a digit
(
(?<day>31(?!.0?[2469]|11)|30(?!.0?2)|
29(?(.0?2)(?=.0?2.(?! #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
(?!\x20BC))|(?:00(?:42|3[0369]|2[147]|1[258]|09)\x20BC)))|(?!.0?2))|
2[0-8]|1\d|0?[1-9])
(?<sep>[-./]) # choose a date separator
(?<month>
(0?[1-9])|1[012]) #end of month check
(?# The maximum number of days allowed for a month has
already been checked for in the month check.
If you made it this far the number of day is
within the range for the given month)
\k<sep> # Match the same date separator choosen before.
(?<year>(?=(?:00(?:4[0-5]|[0-3]?\d)\x20BC)|(?:\d{4}(?:\z|(?:\x20\d))))\d{4}(?:\x20BC)? # a four digit year. Use leading zeros if needed
)
(?(?=\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 |
dd-mm-yyyy Datetime for AD, with leap year.
See http://blogs.regexadvice.com/mash/archive/2004/04/23/1021.aspx for details on this and similar regexs |
Matches |
30-4-2004 | 29/2/2004 3:35 PM | 23:00:00 |
Non-Matches |
1/31/2004 | 23:23 AM | 29/2/2005 |
Author |
Rating:
Not yet rated.
Michael Ash
|
Title |
Test
Details
Pattern Title
|
Expression |
^(([1-9]{1})|([0-1][0-9])|([1-2][0-3])):([0-5][0-9])$ |
Description |
Matches 24 hour time format. |
Matches |
00:00 | 23:59 | 10:10 |
Non-Matches |
24:00 | 00:60 | 25:61 |
Author |
Rating:
Not yet rated.
jeremy chapman
|
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:
Not yet rated.
Knut Hamang
|
Title |
Test
Details
Pattern Title
|
Expression |
^((31(?!\ (Apr(il)?|June?|(Sept|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)?|(Sept|Nov|Dec)(ember)?)\ ((1[6-9]|[2-9]\d)\d{2})$ |
Description |
|
Matches |
21 feb 2004 |
Non-Matches |
30 feb2004 |
Author |
Rating:
Not yet rated.
anil agarwal
|
Title |
Test
Details
Pattern Title
|
Expression |
^(([1-9]{1})|([0-1][1-2])|(0[1-9])|([1][0-2])):([0-5][0-9])(([aA])|([pP]))[mM]$ |
Description |
Matches 12 hour time format |
Matches |
1:00Am | 12:59pM | 05:05pm |
Non-Matches |
00:00am | 05:60pm | 1:00 |
Author |
Rating:
Not yet rated.
jeremy chapman
|
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?((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$ |
Description |
|
Matches |
12/12/2003 |
Non-Matches |
31/02/203 |
Author |
Rating:
Not yet rated.
hayri hayri
|
Title |
Test
Details
Pattern Title
|
Expression |
^([0]\d|[1][0-2])\/([0-2]\d|[3][0-1])\/([2][01]|[1][6-9])\d{2}(\s([0]\d|[1][0-2])(\:[0-5]\d){1,2})*\s*([aApP][mM]{0,2})?$ |
Description |
This is a combination of a few regular expressions found on this site. It allows for a flexible date and time combination, but requires a 12-hour clock (am/pm). Many versions of the am/pm are supported. |
Matches |
12/31/2002 | 12/31/2002 08:00 | 12/31/2002 08:00 AM |
Non-Matches |
12/31/02 | 12/31/2002 14:00 |
Author |
Rating:
Not yet rated.
Bill LaPrade
|
Title |
Test
Details
Pattern Title
|
Expression |
^(([0]?[1-9]|1[0-2])(:)([0-5][0-9]))$ |
Description |
This time validation expression accepts an hour between 1 and 9 (with optional leading zero) and minutes between 01 and 59. This is primarily for use with an AM/PM drop down list or radio button. |
Matches |
09:00 | 9:00 | 11:35 |
Non-Matches |
13:00 | 9.00 | 6:60 |
Author |
Rating:
Not yet rated.
Ken Madden
|
Title |
Test
Details
Pattern Title
|
Expression |
([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) |
Description |
Checks for Date in the typical MySQL DB Format. Not mutch but simple to for converting to German date format:
$date = "2003-12-03";
if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs))
{
echo "$regs[3].$regs[2].$regs[1]"; // prints 03.12.2003
} |
Matches |
2002-11-03 | 2007-17-08 | 9999-99-99 |
Non-Matches |
2002/17/18 | 2002.18.45 | 18.45.2002 |
Author |
Rating:
Not yet rated.
Mike T Spike
|
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:
Not yet rated.
martin devos
|
Title |
Test
Details
Pattern Title
|
Expression |
(^([0-9]|[0-1][0-9]|[2][0-3]):([0-5][0-9])(\s{0,1})(AM|PM|am|pm|aM|Am|pM|Pm{2,2})$)|(^([0-9]|[1][0-9]|[2][0-3])(\s{0,1})(AM|PM|am|pm|aM|Am|pM|Pm{2,2})$) |
Description |
Validate “Time” Data to Work with SQL Server
This is a fix (I hope) for a problem with the original expression. It originally allowed any combination of am or pm. For example: ma, aa, mm, mp, etc. |
Matches |
8am | 8 am | 8:00 am |
Non-Matches |
8a | 8 a | 8:00 a |
Author |
Rating:
Not yet rated.
Greg Burns
|
Title |
Test
Details
Pattern Title
|
Expression |
^ *(1[0-2]|[1-9]):[0-5][0-9] *(a|p|A|P)(m|M) *$ |
Description |
validate 12-hour time with am/pm after it, with optional spaces before or after, and optionally between time and am/pm. |
Matches |
12:00am | 1:00 PM | 12:59 pm |
Non-Matches |
0:00 | 0:01 am | 13:00 pm |
Author |
Rating:
Not yet rated.
Jim Tebbel
|
Title |
Test
Details
Pattern Title
|
Expression |
^(([0]?[0-5][0-9]|[0-9]):([0-5][0-9]))$ |
Description |
This regex is to validate the time of a ~60 minute CD where the most time on the CD is 59:59 (minutes:seconds). It is derived from Ken Madden's time regex for a project for Erik Porter (Windows/Web guru). Written by Jason Gaylord. |
Matches |
30:05 | 5:05 | 02:59 |
Non-Matches |
25:7 | 5m:16 | 60:60 |
Author |
Rating:
Not yet rated.
Jason N. Gaylord
|
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:
Not yet rated.
Carlos R. L. Rodrigues
|
Title |
Test
Details
Pattern Title
|
Expression |
^((([0]?[1-9]|1[0-2])(:|\.)(00|15|30|45)?( )?(AM|am|aM|Am|PM|pm|pM|Pm))|(([0]?[0-9]|1[0-9]|2[0-3])(:|\.)(00|15|30|45)?))$ |
Description |
This expression will allow a time value with 15 minute increments. It will not accept seconds. You can use either US time or Military time format. |
Matches |
1:00 PM | 6:45 am | 17:30 |
Non-Matches |
4:32 am | 5:30:00 am | 17:01 |
Author |
Rating:
Not yet rated.
Rick Yokum
|
Title |
Test
Details
Pattern Title
|
Expression |
^(([0]?[1-9]|[1][0-2])[\/|\-|\.]([0-2]\d|[3][0-1]|[1-9])[\/|\-|\.]([2][0])?\d{2}\s+((([0][0-9]|[1][0-2]|[0-9])[\:|\-|\.]([0-5]\d)\s*([aApP][mM])?)|(([0-1][0-9]|[2][0-3]|[0-9])[\:|\-|\.]([0-5]\d))))$ |
Description |
MM-DD-20YY HH:MM AP
MM-DD-20YY H:MM AP
MM-DD-20YY HH:MM
MM-DD-20YY H:MM
MM-DD-YY HH:MM AP
MM-DD-YY H:MM AP
MM-DD-YY HH:MM
MM-DD-YY H:MM
M-D-YY HH:MM AP
M-D-YY H:MM AP
M-D-YY HH:MM
M-D-YY H:MM
where - can be / or - or .
where : can be : or - or .
Definition:
^( ;Start of Line
([0]?[1-9]|[1][0-2]) ;00-09 or 10-12 or 1-9
[\/|\-|\.] ;/ or - or .
([0-2]\d|[3][0-1]|[1-9]) ;00-29 or 30-31 or 1-9
[\/|\-|\.] ;/ or - or .
([2][0])?\d{2} ;2000-2099 or 00-99
\s+ ;one or more spaces
( ;must be either 12H notation w/AM|PM
(
([0][0-9]|[1][0-2]|[0-9])
[\:|\-|\.] ;: or - or .
([0-5]\d) ;01 thru 59
\s* ;zero or more spaces
([aApP][mM])? ;nothing or AM or PM (case insensitive)
)
| ;or 24H notation w/out AM|PM
(
([0-1][0-9]|[2][0-3]|[0-9]) ;00-19 or 20-23
[\:|\-|\.] ;: or - or .
([0-5]\d) ;00-59
)
)
)$ ;End of Line
|
Matches |
01/01/2002 04:42 | 5-12-02 04:42 AM | 01.01/02 04-42aM |
Non-Matches |
01-12-1999 4:50PM | 01-12-2002 15:10PM | 01-12-002 8:20PM |
Author |
Rating:
Not yet rated.
Bob Duffett
|
Displaying page
of
pages;
Items to