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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
(^([0-9]|[0-1][0-9]|[2][0-3]):([0-5][0-9])$)|(^([0-9]|[1][0-9]|[2][0-3])$)
Description
Matches a string if it is a valid time in the format of HH:MM / H:MM / HH / H
Matches
10:35 | 9:20 | 23
Non-Matches
24:00 | 20 PM | 20:15 PM
Author Rating: The rating for this expression. Nacho Varas
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: How come 0 is valid
Name: Raja Chava
Date: 1/26/2011 5:48:18 PM
Comment:
It says 0 is a valid time. but 00 is invalid. Please fix the 0 case.


Title: it's good, but it does not perfectly what it shoud
Name: Shoto
Date: 5/30/2003 9:23:35 AM
Comment:
try this (^([0-9]|[0-1][0-9]|[2][0-3])):(([0-5][0-9])$|([0-9])$)


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