Title |
Test
Find
Time
|
Expression |
^((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))$|^([01]\d|2[0-3])(:[0-5]\d){0,2}$ |
Description |
This RE validates times patterns. |
Matches |
1 AM | 23:00:00 | 5:29:59 PM |
Non-Matches |
13 PM | 13:60:00 | 00:00:00 AM |
Author |
Rating:
Michael Ash
|
Source |
Michael Ash |
Your Rating |
|
Title: Senior A/P
Name: Steve Malikoff
Date: 3/17/2011 8:46:58 PM
Comment:
Works just fine, two slight improvements:
1) Change the '\ ' (slosh-space) to '\s?' (slosh-s-questionmark) to allow a space or no space gap ie. 4:20 PM or 4:20PM
2)Expand the '[AP]M' to '[AaPp][Mm]' to allow lowercase
Title: erer
Name: erer
Date: 1/7/2007 5:02:14 AM
Comment:
ere http://regexlib.com/REDetails.aspx?regexp_id=370&commentId=15014
Title: Web Developer
Name: Ismail Mayat
Date: 7/14/2004 10:48:55 AM
Comment:
Excellent helped alot on regular expression validator in asp.net page where i had a time field text box that needed validation.
Title: Developer
Name: Chiu Kwing
Date: 3/16/2004 2:09:26 AM
Comment:
Very nice. Technically helpful. but it will be nicer if a caption (a large) is provided for each regularexpression