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*(?'num'\d+(\.\d+)?)\s*(?'unit'((w(eek)?)|(wk)|(d(ay)?)|(h(our)?)|(hr))s?)(\s*$)
Description
Validates Microsoft Project-type duration entries. Accepts a number and a unit. The number part can be integer or decimal. The unit can be several variations of weeks, days, and hours: e.g., w, wk, week, ws, wks, weeks are all valid. Whitespace between the number and the unit is optional: e.g., 1d, 2 days, 3.5w are all valid. Captures the number value in a group named num and the unit string in a group named 'unit'.
Matches
1 day | 3.5 w | 6hrs
Non-Matches
1 | 6. days | 1 week 2 d
Author Rating: Not yet rated. Steve Fisher
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

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