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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^(\d{1,2})(\s?(H|h)?)(:([0-5]\d))?$
Description
Validates hours and minutes. Allows for entry in the form of hours:minutes with optional minutes and optional hours indicator (H or h).
Matches
1h | 1:45 | 45
Non-Matches
1a | 145 | 1:99
Author Rating: Not yet rated. Andrew Yeaman
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: Yes
Name: Andrew Yeaman
Date: 2/4/2004 5:35:13 PM
Comment:
Thanks Darren!


Title: Would it be better...
Name: Darren Neimke
Date: 2/4/2004 3:29:45 AM
Comment:
... if you coded it so that the "minutes" part of the time was restricted to a number between 00 and 59? Something like this maybe: ^(\d{1,2})(\s?(H|h)?)(:([0-5]\d))?$ This would accept something like: 99h:59 But fail against: 99h:99


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