views:

25

answers:

1

Dear all,

I have searched for a while and can't seem to find anything that's related to this.

I need to validate an ISO 8601 time interval. There is loads of stuff about ISO 8601 date times but i specifically need interval. I am using a regex and this is what I have so far;

Regex regEx = new Regex(@"^P((\d+)Y)((\d+)M)((\d+)D)(T)((\d+)H)((\d+)M)((\d+((.)?(\d)?(\d)?))S)$");

So basically this checks if the input string is fully formed eg P0Y0M1DT1H2M2.01S would be validated but the standard states that smaller strings such as PT4S should be accepted too.

If anyone can help me with this I would be much appreciated. I've been reading up on conditional regex but not too sure how to work it.

Many thanks.

A: 

After all i did find the answer as part of a Scorm related question.

link is here if anyone manages to stumble across my post first;

http://stackoverflow.com/questions/1307347/scorm-2004-time-format-regular-expression

Shannow