134 regular expressions found in this category!
Displaying page
of
pages;
Items to
Title |
Test
Details
Pattern Title
|
Expression |
^([1][12]|[0]?[1-9])[\/-]([3][01]|[12]\d|[0]?[1-9])[\/-](\d{4}|\d{2})$ |
Description |
Matches dates with the following format
Month - either MM (like 01) or M (like 1) - from 1 to 12
Day - either DD (like 01) or D ( like 1) - from 1 to 31
Year - either YYYY ( like 1998) or YY (like 98)
Separater - either - or / |
Matches |
11-02-02 | 1-25-2002 | 01/25/2002 |
Non-Matches |
13-02-02 | 11.02.02 | 11/32/2002 |
Author |
Rating:
Not yet rated.
Mekonnen Mekonnen
|
Title |
Test
Details
Pattern Title
|
Expression |
^(|(0[1-9])|(1[0-2]))\/((0[1-9])|(1\d)|(2\d)|(3[0-1]))\/((\d{4}))$ |
Description |
This expression matches dates formatted as MM/DD/YYYY where months and days must be 2 digits each, zero padded. It is not perfect - it allows DD to be from 01 to 31 regardless of the month. |
Matches |
01/01/2001 | 02/30/2001 | 12/31/2002 |
Non-Matches |
1/1/02 | 1/1/2002 | 1/25/2002 |
Author |
Rating:
Not yet rated.
Steven Smith
|
Title |
Test
Details
Pattern Title
|
Expression |
^(0[1-9]|1[0-2])\/((0[1-9]|2\d)|3[0-1])\/(19\d\d|200[0-3])$ |
Description |
This expression is an attempt to match the most obvious features of a valid date in American/US format of the form mm/dd/yyyy for any year 1900 through 2003. It can easily be adapted for different date ranges. It matches any date where the day part is any number 01-31, the month part is any number 01-12, and the year part is any number 1900-2003. The only invalid dates that it matches are ones where the day part may be in the range 01-31 but that range might not be valid for the specified month. An example of an invalid date that it would allow to pass through would be 11/31/2002. This date is invalid because 11/31 of any year does not exist, but this expression would allow it pass through since the day part is in the range 01-31.
This regular expression has been used successfully in ASP with VBScript using the windows scripting library RegExp object. |
Matches |
12/31/2003 | 01/01/1900 | 11/31/2002 |
Non-Matches |
1/1/2002 | 01/01/02 | 01/01/2004 |
Author |
Rating:
Not yet rated.
Josh Bailyr
|
Title |
Test
Details
Pattern Title
|
Expression |
^\d{1,2}\/\d{2,4}$ |
Description |
Accepts 1-2 digits followed by a slash followed by 2-4 digits. Useful for numeric month/year entry. |
Matches |
9/02 | 09/2002 | 09/02 |
Non-Matches |
Fall 2002 | Sept 2002 |
Author |
Rating:
Not yet rated.
Mike Hensley
|
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:
Not yet rated.
Koen Hoorelbeke
|
Title |
Test
Details
Pattern Title
|
Expression |
^( [1-9]|[1-9]|0[1-9]|10|11|12)[0-5]\d$ |
Description |
Matches a 12-hour time value expressed as either 4 numeric digits, 3 numeric digits, or a space and 3 numeric digits. 3 digit times (930) can be expressed with leading 0's (0930) or not. AM/PM designation is not included in this expression. |
Matches |
1145 | 933 | 801 |
Non-Matches |
0000 | 1330 | 8:30 |
Author |
Rating:
Not yet rated.
Steven Smith
|
Title |
Test
Details
Pattern Title
|
Expression |
^((((([13578])|(1[0-2]))[\-\/\s]?(([1-9])|([1-2][0-9])|(3[01])))|((([469])|(11))[\-\/\s]?(([1-9])|([1-2][0-9])|(30)))|(2[\-\/\s]?(([1-9])|([1-2][0-9]))))[\-\/\s]?\d{4})(\s((([1-9])|(1[02]))\:([0-5][0-9])((\s)|(\:([0-5][0-9])\s))([AM|PM|am|pm]{2,2})))?$ |
Description |
This expression can be used validate a datetime column from SQL Server. Big parts of it where taken from other samples on RegexLib. Please feel free to take it apart and improve it. |
Matches |
3/3/2003 | 3/3/2002 3:33 pm | 3/3/2003 3:33:33 am |
Non-Matches |
13/1/2002 | 3/3/2002 3:33 | 31/3/2002 |
Author |
Rating:
Not yet rated.
Scott Watermasysk Watermasysk
|
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:
Not yet rated.
Steve Valaitis
|
Title |
Test
Details
Pattern Title
|
Expression |
^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?: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]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$ |
Description |
This expression validates dates in the ITALIAN d/m/y format from 1/1/1600 - 31/12/9999. 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 since it could be any century (1900, 2000, 2100). Days and months must be 1 or 2 digits and may have leading zeros. Years must be 2 or 4 digit years. 4 digit years must be between 1600 and 9999. Date separator may be a slash (/), dash (-), or period (.)
Thanks to Michael Ash for US Version |
Matches |
29/02/1972 | 5-9-98 | 10-11-2002 |
Non-Matches |
29/02/2003 | 12/13/2002 | 1-1-1500 |
Author |
Rating:
Not yet rated.
Marco Storti
|
Title |
Test
Details
Pattern Title
|
Expression |
((0[1-9])|(1[02]))/\d{2} |
Description |
Fromat check for MM/YY, checks month is 1-12 and any 2 digit year. |
Matches |
01/00 | 12/99 |
Non-Matches |
13/00 | 12/AS |
Author |
Rating:
Not yet rated.
Andrew Balaschak
|
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:
Not yet rated.
Matt Adams
|
Title |
Test
Details
Pattern Title
|
Expression |
(((0[13578]|10|12)([-./])(0[1-9]|[12][0-9]|3[01])([-./])(\d{4}))|((0[469]|11)([-./])([0][1-9]|[12][0-9]|30)([-./])(\d{4}))|((2)([-./])(0[1-9]|1[0-9]|2[0-8])([-./])(\d{4}))|((2)(\.|-|\/)(29)([-./])([02468][048]00))|((2)([-./])(29)([-./])([13579][26]00))|((2)([-./])(29)([-./])([0-9][0-9][0][48]))|((2)([-./])(29)([-./])([0-9][0-9][2468][048]))|((2)([-./])(29)([-./])([0-9][0-9][13579][26]))) |
Description |
My meager attempt at a date validator with leap years using a strict mm/dd/yyyy format. |
Matches |
02/29/2084 | 01/31/2000 | 11/30/2000 |
Non-Matches |
02/29/2083 | 11/31/2000 | 01/32/2000 |
Author |
Rating:
Not yet rated.
Jason West
|
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:
Not yet rated.
Michael Ash
|
Title |
Test
Details
Pattern Title
|
Expression |
^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\,*\s\s*\d{4}$|^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\,*\s\d{4}$|^(January|February|March|April|May|June|July|August|September|October|November|December)\,*\s\d{4}$|^(january|february|march|april|may|june|july|august|september|october|november|december)\,*\s\d{4}$ |
Description |
Best Use validation to accept a valid "MonthName(,) Year".
It can validate an entry with or without comma (,).
|
Matches |
January 2004 | Jan, 2004 | january 2003 |
Non-Matches |
Janu 2004 | jAn, 2004 | January,2003 |
Author |
Rating:
Not yet rated.
Elmer Cadelina
|
Title |
Test
Details
Pattern Title
|
Expression |
^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/(\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/(\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/(\d{2}))|(29\/02\/((0[48]|[2468][048]|[13579][26])|(00))))$ |
Description |
Matching : dd/MM/yy
Leap years compatible
Italian style, just for more fun.
Please, don't forget to rate it if you use it. THX
|
Matches |
31/12/75 | 29/02/00 | 29/02/04 |
Non-Matches |
01/13/01 | 29/02/01 | 29/02/2004 |
Author |
Rating:
Not yet rated.
Dany Lauener
|
Title |
Test
Details
Pattern Title
|
Expression |
^(([8]))$|^((([0-7]))$|^((([0-7])).?((25)|(50)|(5)|(75)|(0)|(00))))$ |
Description |
Time off hours edit for quarter hour(s) less than eight. |
Matches |
0.25 | 7.75 | 8 |
Non-Matches |
8.25 | 7.15 | 0.15 |
Author |
Rating:
Not yet rated.
Bob Kranson
|
Title |
Test
Details
Pattern Title
|
Expression |
^(?<From>(JANUARY|FEBRUARY|MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER|[ ]|,|/|[0-9])+)(-|–|:|TO)?(?<To>(JANUARY|FEBRUARY|MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER|[ ]|,|/|[0-9]|PRESENT)+)+(:)* |
Description |
This regular expression will match date given in any format expcept (mmm). Its speciality is that it divides dates into <from> part and <to> part. Use Groups to access these parts.
e.g. JANUARY 1998 TO JUNE 2000
<From>="JANUARY 1998"
<to>="JUNE 2000"
|
Matches |
JANUARY 2000 | 19-01-2000 | 12/11/2000 |
Non-Matches |
"Hello it is ordinary text" | "non -date text" |
Author |
Rating:
Not yet rated.
Manpreet Grewal
|
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 |
Validates date format by DD MMM YYYY. Validates days for each month also.
Ensures that month is uppercase. |
Matches |
09 MAY 1981 | 28 JAN 2004 | 8 JUL 2006 |
Non-Matches |
29 FEB 2003 | 28 Oct 2000 | 9 APR 03 |
Author |
Rating:
Not yet rated.
Rohan Pathare
|
Title |
Test
Details
Pattern Title
|
Expression |
^((31(?! (FEB|APR|JUN|SEP|NOV)))|(30|29)|(0[1-9])|1\d|2[0-8]) (JAN|FEB|MAR|MAY|APR|JUL|JUN|AUG|OCT|SEP|NOV|DEC)$ |
Description |
|
Matches |
09 MAY | 30 FEB | 31 JAN |
Non-Matches |
31 SEP | 09 May |
Author |
Rating:
Not yet rated.
Rohan Pathare
|
Title |
Test
Details
mm/dd/yyyy Julian and Gregrian Datetime
|
Expression |
(?#Calandar from January 1st 45 BC to December 31, 9999
in mm/dd/yyyy format)
(?!
(?:10(?<sep>[-./])(?:0?[5-9]|1[0-4])\k<sep>(?:1582))| #Missing days from 1582
(?:0?9(?<sep>[-./])(?:0?[3-9]|1[0-3])\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
(
(?<month>
(0?[13578])|1[02]| #months with 31 days
(0?[469]|11)(?!.31)| # months with 30 days
0?2 # February
(?(.29) # if feb 29th check for valid leap year
(?=.29.
(?! #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))
)| # else if not Feb 29
(?!.3[01]) # and day not Feb 30 or 31
) #end Leap year check
) #end of month check
(?<sep>[-./]) # choose a date separator
(?<day>0?[1-9]|[12]\d|3[01]) #days between 1-31
(?# 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.
(?!0000) # There is no year 0
(?<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 |
Datetime for Julian and Gregorian Calenders
Matchs dates from 0001 A.D. 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. |
Matches |
12/25/0004 | 12/31/0001 BC 2:15 AM | 2-29-2004 09:00 |
Non-Matches |
00/00/0000 | 2-29-2100 | 10/8/1582 |
Author |
Rating:
Not yet rated.
Michael Ash
|
Displaying page
of
pages;
Items to