<?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: An IE lastIndex Bug with Zero-Length Regex Matches</title>
	<atom:link href="http://blog.stevenlevithan.com/archives/exec-bugs/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.stevenlevithan.com/archives/exec-bugs</link>
	<description>A JavaScript and regular expression centric blog</description>
	<lastBuildDate>Thu, 11 Mar 2010 18:49:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: IE and Regex.exec() &#124; OpenBox</title>
		<link>http://blog.stevenlevithan.com/archives/exec-bugs/comment-page-1#comment-45718</link>
		<dc:creator>IE and Regex.exec() &#124; OpenBox</dc:creator>
		<pubDate>Mon, 04 Jan 2010 20:52:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/exec-bugs#comment-45718</guid>
		<description>[...] and we get the results we expected.Â  Somewhat related to this item is the following interesting lastIndex bug in IE with zero-length matches.Â  Hopefully, this will save someone a headache when trying to debug using Javascript [...]</description>
		<content:encoded><![CDATA[<p>[...] and we get the results we expected.Â  Somewhat related to this item is the following interesting lastIndex bug in IE with zero-length matches.Â  Hopefully, this will save someone a headache when trying to debug using Javascript [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blog.stevenlevithan.com/archives/exec-bugs/comment-page-1#comment-17444</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Wed, 16 Apr 2008 03:38:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/exec-bugs#comment-17444</guid>
		<description>Jan, as far as I can tell, the spec doesn&#039;t technically contradict itself on this issue, although it might be poorly designed and/or defy the common-sense expectation that searches wouldn&#039;t continually start at the same position after an empty string match. The problem is that ECMAScript tries to use lastIndex for two purposes, which is one too many. lastIndex, as exposed to the user for global regexes used with methods that deal with lastIndex at all (String.prototype.search doesn&#039;t, for example), is always the end of the last match or zero (unless the user tampers with the value themselves, which can be a useful trick). How lastIndex is used internally by some methods is not really any concern of the user&#039;s, and is likely to differ between implementations. exec is the core regex search method from which all others can be derived. It is not specifically designed to iterate over strings, although that is one of its more common uses.

The ECMAScript design for lastIndex actually adds useful information when using the test method with a global regex&#8212;it tells you how far in the string you&#039;ve already tested, which could not otherwise be determined. But then, due to the IE bug (or spec violation) you can&#039;t reliably use it for that purpose anyway.

If you feel strongly that this should be classified as a bug in the spec, there is an existing Firefox ticket at https://bugzilla.mozilla.org/show_bug.cgi?id=252356 which can be added to, and the ECMAScript 4 bug database at http://bugs.ecmascript.org</description>
		<content:encoded><![CDATA[<p>Jan, as far as I can tell, the spec doesn&#8217;t technically contradict itself on this issue, although it might be poorly designed and/or defy the common-sense expectation that searches wouldn&#8217;t continually start at the same position after an empty string match. The problem is that ECMAScript tries to use lastIndex for two purposes, which is one too many. lastIndex, as exposed to the user for global regexes used with methods that deal with lastIndex at all (String.prototype.search doesn&#8217;t, for example), is always the end of the last match or zero (unless the user tampers with the value themselves, which can be a useful trick). How lastIndex is used internally by some methods is not really any concern of the user&#8217;s, and is likely to differ between implementations. exec is the core regex search method from which all others can be derived. It is not specifically designed to iterate over strings, although that is one of its more common uses.</p>
<p>The ECMAScript design for lastIndex actually adds useful information when using the test method with a global regex&mdash;it tells you how far in the string you&#8217;ve already tested, which could not otherwise be determined. But then, due to the IE bug (or spec violation) you can&#8217;t reliably use it for that purpose anyway.</p>
<p>If you feel strongly that this should be classified as a bug in the spec, there is an existing Firefox ticket at <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=252356" rel="nofollow">https://bugzilla.mozilla.org/show_bug.cgi?id=252356</a> which can be added to, and the ECMAScript 4 bug database at <a href="http://bugs.ecmascript.org" rel="nofollow">http://bugs.ecmascript.org</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jan Goyvaerts</title>
		<link>http://blog.stevenlevithan.com/archives/exec-bugs/comment-page-1#comment-17405</link>
		<dc:creator>Jan Goyvaerts</dc:creator>
		<pubDate>Tue, 15 Apr 2008 07:56:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/exec-bugs#comment-17405</guid>
		<description>I&#039;m afraid I have to disagree.  The ECMA-262 standard contradicts itself.  Firefox slavishly follows the implementation steps for regexp.exec(), while Internet Explorer follows the definition of the lastIndex property which does require the +1 in case of a zero-length match.  IE makes the more useful choice.  Incrementing lastIndex is what all regex engines do, and is the only way to avoid an infinite loop.  The pingback above explains my position in detail, with references to the standard.</description>
		<content:encoded><![CDATA[<p>I&#8217;m afraid I have to disagree.  The ECMA-262 standard contradicts itself.  Firefox slavishly follows the implementation steps for regexp.exec(), while Internet Explorer follows the definition of the lastIndex property which does require the +1 in case of a zero-length match.  IE makes the more useful choice.  Incrementing lastIndex is what all regex engines do, and is the only way to avoid an infinite loop.  The pingback above explains my position in detail, with references to the standard.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Regex Guru &#187; Watch Out for Zero-Length Matches</title>
		<link>http://blog.stevenlevithan.com/archives/exec-bugs/comment-page-1#comment-17404</link>
		<dc:creator>Regex Guru &#187; Watch Out for Zero-Length Matches</dc:creator>
		<pubDate>Tue, 15 Apr 2008 07:51:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/exec-bugs#comment-17404</guid>
		<description>[...] tough. Different browsers handle zero-length matches differently. Steven Levithan argues that IE has a bug because it increments lastIndex. Steven&#8217;s observation is correct. When iterating over /b/g.exec(), regex.lastIndex = [...]</description>
		<content:encoded><![CDATA[<p>[...] tough. Different browsers handle zero-length matches differently. Steven Levithan argues that IE has a bug because it increments lastIndex. Steven&#8217;s observation is correct. When iterating over /b/g.exec(), regex.lastIndex = [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
