looking for some solutions? You are welcome.

SOLVED: Regexp matching ISO8601 date/time format

Ole Tange:

I am looking for a regular expression that matches everything in the ISO8601 date/time format - and nothing else. It should match all possible ISO8601 combinations and not just the common 2015-01-17T18:23:02+00:00.

Eg. given a string it should be able to tell me whether it is in ISO8601 format or not.

Examples from Wikipedia that should all be accepted: 2017-06-04, 2017-06-04T20:40:03+00:00, 2017-06-04T20:40:03Z, 20170604T204003Z, 2017-W22, 2017-W22-7, --06-04, 2017-155, P3Y6M4DT12H30M5S, P23DT23H, P4Y, P1M, PT1M, P0.5Y, P0,5Y, P1DT12H, PT36H, P0003-06-04T12:30:05, 2007-03-01T13:00:00Z/2008-05-11T15:30:00Z, 2007-03-01T13:00:00Z/P1Y2M10DT2H30M, P1Y2M10DT2H30M/2008-05-11T15:30:00Z, P1Y2M10DT2H30M, 2007-12-14T13:30/15:30, 2007-11-13/15, 2007-11-13T00:00/15T24:00, R5/2008-03-01T13:00:00Z/P1Y2M10DT2H30M.

The regexp should reject these (as per ISO 8601:2004): 01-01-01, 12-12-12, 17-06-05.

Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered

No comments: