<?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: XRegExp 1.0</title>
	<atom:link href="http://blog.stevenlevithan.com/archives/xregexp-1-0/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.stevenlevithan.com/archives/xregexp-1-0</link>
	<description>A JavaScript and regular expression centric blog</description>
	<lastBuildDate>Sat, 13 Mar 2010 15:18:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Steven Levithan</title>
		<link>http://blog.stevenlevithan.com/archives/xregexp-1-0/comment-page-1#comment-42983</link>
		<dc:creator>Steven Levithan</dc:creator>
		<pubDate>Mon, 02 Nov 2009 15:08:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/xregexp-1-0#comment-42983</guid>
		<description>It is not a Java bug, and it is well specified in the specs for Java, JavaScript, and most other regex flavors. In Java, of course, the singleline option is called dotall (a more descriptive and therefore superior name), and JavaScript doesn&#039;t have a native equivalent (the &lt;code&gt;/s&lt;/code&gt; flag in RegexPal comes from XRegExp, which silently converts the appropriate dots to &lt;code&gt;[\s\S]&lt;/code&gt;).

Lookahead obeys &lt;code&gt;/m&lt;/code&gt; just fine, but &lt;code&gt;/m&lt;/code&gt; has no impact on the dot (whereas &lt;code&gt;/s&lt;/code&gt; does). I think you are a bit confused about what the &lt;code&gt;/m&lt;/code&gt; and &lt;code&gt;/s&lt;/code&gt; flags actually do (this is a common point of confusion since the flags are named so terribly). Please see http://blog.stevenlevithan.com/archives/singleline-multiline-confusing for the details.

&lt;code&gt;XRegExp(&quot;^a(?=.)$&quot;, &quot;ms&quot;).test(&quot;a\n&quot;)&lt;/code&gt; should and does return &lt;code&gt;true&lt;/code&gt;.
&lt;code&gt;XRegExp(&quot;^a(?!.)$&quot;, &quot;ms&quot;).test(&quot;a\n&quot;)&lt;/code&gt; should and does return &lt;code&gt;false&lt;/code&gt;.

This is long-established, cross-library-consistent regex behavior (albeit confusing due to the flag names).</description>
		<content:encoded><![CDATA[<p>It is not a Java bug, and it is well specified in the specs for Java, JavaScript, and most other regex flavors. In Java, of course, the singleline option is called dotall (a more descriptive and therefore superior name), and JavaScript doesn&#8217;t have a native equivalent (the <code>/s</code> flag in RegexPal comes from XRegExp, which silently converts the appropriate dots to <code>[\s\S]</code>).</p>
<p>Lookahead obeys <code>/m</code> just fine, but <code>/m</code> has no impact on the dot (whereas <code>/s</code> does). I think you are a bit confused about what the <code>/m</code> and <code>/s</code> flags actually do (this is a common point of confusion since the flags are named so terribly). Please see <a href="http://blog.stevenlevithan.com/archives/singleline-multiline-confusing" rel="nofollow">http://blog.stevenlevithan.com/archives/singleline-multiline-confusing</a> for the details.</p>
<p><code>XRegExp("^a(?=.)$", "ms").test("a\n")</code> should and does return <code>true</code>.<br />
<code>XRegExp("^a(?!.)$", "ms").test("a\n")</code> should and does return <code>false</code>.</p>
<p>This is long-established, cross-library-consistent regex behavior (albeit confusing due to the flag names).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aeron</title>
		<link>http://blog.stevenlevithan.com/archives/xregexp-1-0/comment-page-1#comment-42958</link>
		<dc:creator>Aeron</dc:creator>
		<pubDate>Mon, 02 Nov 2009 09:03:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/xregexp-1-0#comment-42958</guid>
		<description>Flags: ms
^a(?=.)$ with &quot;a\n&quot; matches but shouldn&#039;t.
^a(?!.)$ with &quot;a\n&quot; does not match but should.

Imo, with multiline enabled a lookAhead should ignore the line terminator (and the rest of the expression) if the following statement is a &#039;$&#039;.</description>
		<content:encoded><![CDATA[<p>Flags: ms<br />
^a(?=.)$ with &#8220;a\n&#8221; matches but shouldn&#8217;t.<br />
^a(?!.)$ with &#8220;a\n&#8221; does not match but should.</p>
<p>Imo, with multiline enabled a lookAhead should ignore the line terminator (and the rest of the expression) if the following statement is a &#8216;$&#8217;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aeron</title>
		<link>http://blog.stevenlevithan.com/archives/xregexp-1-0/comment-page-1#comment-42957</link>
		<dc:creator>Aeron</dc:creator>
		<pubDate>Mon, 02 Nov 2009 08:44:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/xregexp-1-0#comment-42957</guid>
		<description>@Steven

Thanks for the reply.

I&#039;m using FireFox but anyway, I noticed the same problem in JAVA.
JAVA says:
&quot;When in MULTILINE mode $  matches just before a line terminator or the end of the input sequence&quot; (http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#lt)
So when I&#039;m at the end of a line from many lines and have the &#039;m&#039; flag up. I expect, to what java says, that when I preform a lookAhead with &#039;.&#039; from that point _and_ have the &#039;s&#039; flag up that it will not see the line terminator in any possible way.

So for now I presume that a lookAhead will not obey the &#039;m&#039; flag and sees the line terminators not as EOL.

Java bug?
Not specified in the RegEx world?
Another flag to introduce to overcome this?
The end of the world?</description>
		<content:encoded><![CDATA[<p>@Steven</p>
<p>Thanks for the reply.</p>
<p>I&#8217;m using FireFox but anyway, I noticed the same problem in JAVA.<br />
JAVA says:<br />
&#8220;When in MULTILINE mode $  matches just before a line terminator or the end of the input sequence&#8221; (<a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#lt" rel="nofollow">http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#lt</a>)<br />
So when I&#8217;m at the end of a line from many lines and have the &#8216;m&#8217; flag up. I expect, to what java says, that when I preform a lookAhead with &#8216;.&#8217; from that point _and_ have the &#8217;s&#8217; flag up that it will not see the line terminator in any possible way.</p>
<p>So for now I presume that a lookAhead will not obey the &#8216;m&#8217; flag and sees the line terminators not as EOL.</p>
<p>Java bug?<br />
Not specified in the RegEx world?<br />
Another flag to introduce to overcome this?<br />
The end of the world?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven Levithan</title>
		<link>http://blog.stevenlevithan.com/archives/xregexp-1-0/comment-page-1#comment-42951</link>
		<dc:creator>Steven Levithan</dc:creator>
		<pubDate>Mon, 02 Nov 2009 06:25:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/xregexp-1-0#comment-42951</guid>
		<description>@Aeron, no. First of all, RegexPal currently uses an old version of XRegExp (so it&#039;s not a good way to test bugs in the latest version), and secondly, RegexPal uses native JavaScript regex syntax, so it&#039;s not a good way to test XRegExp at all (it&#039;s better for testing your browser&#039;s native regex support).

With your first regex, you have the &lt;code&gt;/s&lt;/code&gt; flag turned on, so it&#039;s absolutely correct that only the second line matches (since the dot matches any character including line beaks). Turning off &lt;code&gt;/s&lt;/code&gt; allows the regex to match both lines, which again is correct. In IE, turning off &lt;code&gt;/s&lt;/code&gt; does not allow the regex to match both lines, but that is because of an IE regex bug (possibly the bug described at http://blog.stevenlevithan.com/archives/regex-lookahead-bug or something similar). You can easily test the difference cross-browser using this stripped down version of your regex: &lt;code&gt;javascript:alert(/\d(?!.)/m.test(&quot;1\r&quot;));&lt;/code&gt;. In IE it returns &lt;code&gt;false&lt;/code&gt;; in other browsers, &lt;code&gt;true&lt;/code&gt;.

With your second regex, again, everything is as it should be.</description>
		<content:encoded><![CDATA[<p>@Aeron, no. First of all, RegexPal currently uses an old version of XRegExp (so it&#8217;s not a good way to test bugs in the latest version), and secondly, RegexPal uses native JavaScript regex syntax, so it&#8217;s not a good way to test XRegExp at all (it&#8217;s better for testing your browser&#8217;s native regex support).</p>
<p>With your first regex, you have the <code>/s</code> flag turned on, so it&#8217;s absolutely correct that only the second line matches (since the dot matches any character including line beaks). Turning off <code>/s</code> allows the regex to match both lines, which again is correct. In IE, turning off <code>/s</code> does not allow the regex to match both lines, but that is because of an IE regex bug (possibly the bug described at <a href="http://blog.stevenlevithan.com/archives/regex-lookahead-bug" rel="nofollow">http://blog.stevenlevithan.com/archives/regex-lookahead-bug</a> or something similar). You can easily test the difference cross-browser using this stripped down version of your regex: <code>javascript:alert(/\d(?!.)/m.test("1\r"));</code>. In IE it returns <code>false</code>; in other browsers, <code>true</code>.</p>
<p>With your second regex, again, everything is as it should be.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aeron</title>
		<link>http://blog.stevenlevithan.com/archives/xregexp-1-0/comment-page-1#comment-42911</link>
		<dc:creator>Aeron</dc:creator>
		<pubDate>Sun, 01 Nov 2009 18:27:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.stevenlevithan.com/archives/xregexp-1-0#comment-42911</guid>
		<description>Related:

http://regexpal.com/?flags=ms&amp;regex=^((25[0-5]&#124;(2[0-4]&#124;1\d&#124;[1-9]%3F)\d)(\.(%3F%3D.)&#124;)){4}%24&amp;input=1.2.3.5.%0A1.2.3.4%0A

Counts both as valid, yet only the 2nd is valid.</description>
		<content:encoded><![CDATA[<p>Related:</p>
<p><a href="http://regexpal.com/?flags=ms&amp;regex=" rel="nofollow">http://regexpal.com/?flags=ms&amp;regex=</a>^((25[0-5]|(2[0-4]|1\d|[1-9]%3F)\d)(\.(%3F%3D.)|)){4}%24&amp;input=1.2.3.5.%0A1.2.3.4%0A</p>
<p>Counts both as valid, yet only the 2nd is valid.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
