RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

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: The rating for this expression. Michael Ash
Source Michael Ash
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

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


Copyright © 2001-2017, RegexAdvice.com | ASP.NET Tutorials