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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find CAP date time
Expression
^(?:[2-9]\d\d\d)-(?:1[012]|0?[1-9])?-(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(?:T))|(?:2[0-8]|1\d|0?[1-9]))T(2[01234]|[01]\d):[0-5]\d:[0-5]\d[+-][01]\d:[0-5]\d$
Description
Matches the strict datetime format for Common Alerting Protocol v1.2 (might be same as earlier versions too). Inspiration and some code came from Michael Ash's http://regexlib.com/REDetails.aspx?regexp_id=610 with tweaks of my own
Matches
2016-04-07T12:29:00-04:00 | 2016-04-07T11:13:00-05:00 | 2016-04-05T00:53:35-04:00
Non-Matches
31/12/2003 11:59:59 PM | 2016-04-07 22:00:01+00:00 | 2016-04-07T22:00:01Z
Author Rating: The rating for this expression. Branden Snyder
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