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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find XSD Duration
Expression
^[-]?P(?!$)(?:(?<year>\d+)+Y)?(?:(?<month>\d+)+M)?(?:(?<days>\d+)+D)?(?:T(?!$)(?:(?<hours>\d+)+H)?(?:(?<minutes>\d+)+M)? (?:(?<seconds>\d+(?:\.\d+)?)+S)?)?$
Description
This expression was derived from Mike Cromwell's version, which matches the XSD schema duration built in type as defined by http://www.w3.org/TR/xmlschema-2/#duration. This version adds named captured groups to assist with extracting the data.
Matches
P1Y2M3DT4H5M6S | P2M3D | -PT4H12.2S
Non-Matches
1Y2M3DT4H | P4H5M | PT2M
Author Rating: Not yet rated. Rob Yacullo
Source Derived from Mike Cromwell's version - http://regexlib.com/REDetails.aspx?regexp_id=1219
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-2025, RegexAdvice.com | ASP.NET Tutorials