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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find 12-Hour Time (HH:MM:SS)
Expression
^(0?[1-9]|1[0-2])(\:)([0-5][0-9])(\:)([0-5][0-9]) (AM|PM)$
Description
This regex validates time strings to ensure they're in the format HH:MM:SS. It accepts from 1:00:00-12:59:59
Matches
12:13:10 AM, 01:42:59 PM, 1:36:22 PM
Non-Matches
13:19:41, 2:52, 3:19 PM
Author Rating: Not yet rated. Nathon Dalton
Source
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: metacharacter '?'
Name: omordha
Date: 12/5/2013 10:55:29 AM
Comment:
I answered my own question. I'm using the format xx:xx:xx, so it works fine without the '?'. Your expression will accept x:xx:xx, which needs the '?' to work.


Title: metacharacter '?'
Name: omordha
Date: 12/5/2013 10:48:58 AM
Comment:
What does the '?' do to this expression? I removed it and it tested fine.


Title: metacharacter '?'
Name: omordha
Date: 12/5/2013 10:47:11 AM
Comment:
What does the '?' do to this expression? I removed it and it tested fine.


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