<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: ISO Date Validation RegEx</title>
	<atom:link href="http://underground.infovark.com/2008/07/22/iso-date-validation-regex/feed/" rel="self" type="application/rss+xml" />
	<link>http://underground.infovark.com/2008/07/22/iso-date-validation-regex/</link>
	<description>The Infovark technology blog</description>
	<lastBuildDate>Thu, 17 Nov 2011 16:06:58 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Andre</title>
		<link>http://underground.infovark.com/2008/07/22/iso-date-validation-regex/comment-page-1/#comment-2442</link>
		<dc:creator>Andre</dc:creator>
		<pubDate>Fri, 01 Jul 2011 00:00:40 +0000</pubDate>
		<guid isPermaLink="false">http://underground.infovark.com/?p=29#comment-2442</guid>
		<description>Hi Cameron,

That is a great regex.  Have you ever complted the full ISO 8601 regex, with intervals, durations, repeat periods?

If you have, it would be very useful for a StratML Specification Schema.

Thank you.

Regards,
Andre</description>
		<content:encoded><![CDATA[<p>Hi Cameron,</p>
<p>That is a great regex.  Have you ever complted the full ISO 8601 regex, with intervals, durations, repeat periods?</p>
<p>If you have, it would be very useful for a StratML Specification Schema.</p>
<p>Thank you.</p>
<p>Regards,<br />
Andre</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cameron Brooks</title>
		<link>http://underground.infovark.com/2008/07/22/iso-date-validation-regex/comment-page-1/#comment-344</link>
		<dc:creator>Cameron Brooks</dc:creator>
		<pubDate>Fri, 19 Feb 2010 02:24:24 +0000</pubDate>
		<guid isPermaLink="false">http://underground.infovark.com/?p=29#comment-344</guid>
		<description>Hey guys. You&#039;re quite correct that my regex didn&#039;t account for fractional time elements. At the time I wrote it I didn&#039;t require it for my application, and I didn&#039;t realize how many people used them for super-precise ISO times. I&#039;ve updated my regex to account for this.

Here are some strings that should match as valid:

2010-02-18T16:23:48.5
2010-02-18T16:23:48,444
2010-02-18T16:23:48,3-06:00
2010-02-18T16:23.4
2010-02-18T16:23,25
2010-02-18T16:23.33+0600
2010-02-18T16.23334444
2010-02-18T16,2283
2009-05-19 143922.500
2009-05-19 1439,55

And here are some strings that should not match as valid:

2009-05-19 146922.500
2010-02-18T16.5:23.35:48
2010-02-18T16:23.35:48
2010-02-18T16:23.35:48.45
2009-05-19 14.5.44
2010-02-18T16:23.33.600
2010-02-18T16,25:23:48,444

Here&#039;s the updated regex that I was able to come up with:

^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]&#124;1[0-2])(\3([12]\d&#124;0[1-9]&#124;3[01]))?&#124;W([0-4]\d&#124;5[0-2])(-?[1-7])?&#124;(00[1-9]&#124;0[1-9]\d&#124;[12]\d{2}&#124;3([0-5]\d&#124;6[1-6])))([T\s]((([01]\d&#124;2[0-3])((:?)[0-5]\d)?&#124;24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]&#124;([\+-])([01]\d&#124;2[0-3]):?([0-5]\d)?)?)?)?$

It still doesn&#039;t account for the duration or time interval part of the ISO 8601 spec, so I guess that&#039;ll have to come at a later date.

Lemme know if you find any bugs.</description>
		<content:encoded><![CDATA[<p>Hey guys. You&#8217;re quite correct that my regex didn&#8217;t account for fractional time elements. At the time I wrote it I didn&#8217;t require it for my application, and I didn&#8217;t realize how many people used them for super-precise ISO times. I&#8217;ve updated my regex to account for this.</p>
<p>Here are some strings that should match as valid:</p>
<p>2010-02-18T16:23:48.5<br />
2010-02-18T16:23:48,444<br />
2010-02-18T16:23:48,3-06:00<br />
2010-02-18T16:23.4<br />
2010-02-18T16:23,25<br />
2010-02-18T16:23.33+0600<br />
2010-02-18T16.23334444<br />
2010-02-18T16,2283<br />
2009-05-19 143922.500<br />
2009-05-19 1439,55</p>
<p>And here are some strings that should not match as valid:</p>
<p>2009-05-19 146922.500<br />
2010-02-18T16.5:23.35:48<br />
2010-02-18T16:23.35:48<br />
2010-02-18T16:23.35:48.45<br />
2009-05-19 14.5.44<br />
2010-02-18T16:23.33.600<br />
2010-02-18T16,25:23:48,444</p>
<p>Here&#8217;s the updated regex that I was able to come up with:</p>
<p>^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$</p>
<p>It still doesn&#8217;t account for the duration or time interval part of the ISO 8601 spec, so I guess that&#8217;ll have to come at a later date.</p>
<p>Lemme know if you find any bugs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan</title>
		<link>http://underground.infovark.com/2008/07/22/iso-date-validation-regex/comment-page-1/#comment-308</link>
		<dc:creator>Bryan</dc:creator>
		<pubDate>Fri, 18 Dec 2009 18:37:10 +0000</pubDate>
		<guid isPermaLink="false">http://underground.infovark.com/?p=29#comment-308</guid>
		<description>Cameron Brooks&#039; solution doesn&#039;t seem to handle fractional sections, FWIW. Other than that it seems to work pretty well.</description>
		<content:encoded><![CDATA[<p>Cameron Brooks&#8217; solution doesn&#8217;t seem to handle fractional sections, FWIW. Other than that it seems to work pretty well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dean</title>
		<link>http://underground.infovark.com/2008/07/22/iso-date-validation-regex/comment-page-1/#comment-221</link>
		<dc:creator>Dean</dc:creator>
		<pubDate>Tue, 26 May 2009 23:44:15 +0000</pubDate>
		<guid isPermaLink="false">http://underground.infovark.com/?p=29#comment-221</guid>
		<description>Quite right, Cameron. The false positives you identified are definite bugs in the regular expression I&#039;d posted.

And the following three false negatives you provided are also bugs:

2009
2009-05
2007-04-05T24:00

The other false negatives you listed are indeed valid ISO 8601 date strings. But the W3C recommendation excludes the day-of-year and week-of-year notation from the XML standard.
http://www.w3.org/TR/NOTE-datetime

So your expression is much better for strict compliance with ISO 8601. For compliance with XML, we&#039;ll need something a little different. But either way, it&#039;s time to update this page!</description>
		<content:encoded><![CDATA[<p>Quite right, Cameron. The false positives you identified are definite bugs in the regular expression I&#8217;d posted.</p>
<p>And the following three false negatives you provided are also bugs:</p>
<p>2009<br />
2009-05<br />
2007-04-05T24:00</p>
<p>The other false negatives you listed are indeed valid ISO 8601 date strings. But the W3C recommendation excludes the day-of-year and week-of-year notation from the XML standard.<br />
<a href="http://www.w3.org/TR/NOTE-datetime" rel="nofollow">http://www.w3.org/TR/NOTE-datetime</a></p>
<p>So your expression is much better for strict compliance with ISO 8601. For compliance with XML, we&#8217;ll need something a little different. But either way, it&#8217;s time to update this page!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cameron Brooks</title>
		<link>http://underground.infovark.com/2008/07/22/iso-date-validation-regex/comment-page-1/#comment-220</link>
		<dc:creator>Cameron Brooks</dc:creator>
		<pubDate>Tue, 19 May 2009 21:33:35 +0000</pubDate>
		<guid isPermaLink="false">http://underground.infovark.com/?p=29#comment-220</guid>
		<description>I was in the same situation as you (needing ISO 8601 validation). Your &quot;works&quot; regex is great, but needed a bit more fine tuning to be truly ISO 8601 compliant. Here are some strings it matches on that should not be matched on:

2009-05-19T14a39r
2009-05-19T14:3924
2009-0519
2009-05-1914:39
2009-05-19r14:39
2009-05-19 14a39a22
200912-01

And here are some valid ISO 8601 dates that it should match on but doesn&#039;t:

2009
2009-12T12:34
2009123
2009-05
2009-123
2009-222
2009-001
2009-W01-1
2009-W51-1
2009-W511
2009W511
2009-05-19 14
2009-W21-2
2009-139
2007-04-05T24:00

(Note that 24:00 is a valid representation of midnight according to ISO 8601, so I changed that.) Obviously, this doesn&#039;t include the duration or time interval aspects of ISO 8601 (I left those out because I didn&#039;t need them).

This is the modified regex I came up with:

^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]&#124;1[0-2])(\3([12]\d&#124;0[1-9]&#124;3[01]))?&#124;W([0-4]\d&#124;5[0-2])-?[1-7]&#124;(00[1-9]&#124;0[1-9]\d&#124;[12]\d{2}&#124;3([0-5]\d&#124;6[1-6])))([T\s](([01]\d&#124;2[0-3])((:?)[0-5]\d)?&#124;24\:?00)?(\15([0-5]\d))?([zZ]&#124;([\+-])([01]\d&#124;2[0-3]):?([0-5]\d)?)?)?)?$

I&#039;d love to hear your input.</description>
		<content:encoded><![CDATA[<p>I was in the same situation as you (needing ISO 8601 validation). Your &#8220;works&#8221; regex is great, but needed a bit more fine tuning to be truly ISO 8601 compliant. Here are some strings it matches on that should not be matched on:</p>
<p>2009-05-19T14a39r<br />
2009-05-19T14:3924<br />
2009-0519<br />
2009-05-1914:39<br />
2009-05-19r14:39<br />
2009-05-19 14a39a22<br />
200912-01</p>
<p>And here are some valid ISO 8601 dates that it should match on but doesn&#8217;t:</p>
<p>2009<br />
2009-12T12:34<br />
2009123<br />
2009-05<br />
2009-123<br />
2009-222<br />
2009-001<br />
2009-W01-1<br />
2009-W51-1<br />
2009-W511<br />
2009W511<br />
2009-05-19 14<br />
2009-W21-2<br />
2009-139<br />
2007-04-05T24:00</p>
<p>(Note that 24:00 is a valid representation of midnight according to ISO 8601, so I changed that.) Obviously, this doesn&#8217;t include the duration or time interval aspects of ISO 8601 (I left those out because I didn&#8217;t need them).</p>
<p>This is the modified regex I came up with:</p>
<p>^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])-?[1-7]|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s](([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)?(\15([0-5]\d))?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$</p>
<p>I&#8217;d love to hear your input.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bookmarks about Iso</title>
		<link>http://underground.infovark.com/2008/07/22/iso-date-validation-regex/comment-page-1/#comment-130</link>
		<dc:creator>Bookmarks about Iso</dc:creator>
		<pubDate>Tue, 09 Dec 2008 20:15:46 +0000</pubDate>
		<guid isPermaLink="false">http://underground.infovark.com/?p=29#comment-130</guid>
		<description>[...] - bookmarked by 2 members originally found by VissyLinch09 on 2008-11-13  ISO Date Validation RegEx  http://underground.infovark.com/2008/07/22/iso-date-validation-regex/ - bookmarked by 5 members [...]</description>
		<content:encoded><![CDATA[<p>[...] &#8211; bookmarked by 2 members originally found by VissyLinch09 on 2008-11-13  ISO Date Validation RegEx  <a href="http://underground.infovark.com/2008/07/22/iso-date-validation-regex/" rel="nofollow">http://underground.infovark.com/2008/07/22/iso-date-validation-regex/</a> &#8211; bookmarked by 5 members [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

