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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^\s*-?(\d*\.)?([0-2])?[0-9]:([0-5])?[0-9]:([0-5])?[0-9](\.[0-9]{1,7})?\s*$
Description
This should be the pattern described in the documentation for the .NET TimeSpan.Parse method - generally parses time spans. From the .NET docs: public static TimeSpan Parse(string s); The s parameter contains a specification of the form: [ws][-][d.]hh:mm:ss[.ff][ws] Items in square brackets ([ and ]) are optional, colons and periods (: and .) are literal characters, and other items are as follows. Item Description ws optional white space "-" optional minus sign indicating a negative time "d" optional days "hh" hours, ranging from 0 to 23 "mm" minutes, ranging from 0 to 59 "ss" seconds, ranging from 0 to 59 "ff" optional fractional seconds, from 1 to 7 decimal digits
Matches
10:12:34 | 932323.9:00:32.3420
Non-Matches
10:20:80
Author Rating: Not yet rated. Philipp Schumann
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: Too broad
Name: Grim
Date: 2/5/2008 2:59:24 PM
Comment:
This matches 29:00:00


Title: Revision
Name: Philipp Schumann
Date: 2/10/2005 12:14:58 PM
Comment:
Thanks Ryan, so the updated version would be: ^\s*-?(\d*\.)?([0-1]?[0-9])|([0-2][0-3]):([0-5])?[0-9]:([0-5])?[0-9](\.[0 -9]{1,7})?\s*$


Title: Hours Is Not Correct
Name: Ryan
Date: 2/10/2005 10:08:17 AM
Comment:
the pattern to match the hours is not correct. It will match 27:00:00 which is not valid. Change it to be: [0-1][0-9]|[0-2][0-3]


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