<?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: Rhapsody Greasemonkey Script: Optimizing Text Manipulation in Javascript with Regular Expressions</title>
	<atom:link href="http://www.embracingchaos.com/2007/04/rhapsody_grease-2.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.embracingchaos.com/2007/04/rhapsody_grease-2.html</link>
	<description>Analysis of Trends in Technology, Business, Society</description>
	<lastBuildDate>Wed, 25 Jan 2012 18:52:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: leodirac</title>
		<link>http://www.embracingchaos.com/2007/04/rhapsody_grease-2.html/comment-page-1#comment-367</link>
		<dc:creator>leodirac</dc:creator>
		<pubDate>Wed, 13 Jun 2007 21:48:37 +0000</pubDate>
		<guid isPermaLink="false">http://wp.embracingchaos.com/2007/04/rhapsody_grease-2.html#comment-367</guid>
		<description>&lt;p&gt;Thanks for pointing that our Eric, and for the detailed off-line explanation.  I should really run some performance tests on FF to check how they&#039;ve implemented it.&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>Thanks for pointing that our Eric, and for the detailed off-line explanation.  I should really run some performance tests on FF to check how they&#39;ve implemented it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Lippert</title>
		<link>http://www.embracingchaos.com/2007/04/rhapsody_grease-2.html/comment-page-1#comment-366</link>
		<dc:creator>Eric Lippert</dc:creator>
		<pubDate>Wed, 23 May 2007 06:46:55 +0000</pubDate>
		<guid isPermaLink="false">http://wp.embracingchaos.com/2007/04/rhapsody_grease-2.html#comment-366</guid>
		<description>&lt;p&gt;I don&#039;t doubt that for typical data the regexp algorithm is O(N), or that it is typically faster than the O(MN) naive solution.  &lt;/p&gt;

&lt;p&gt;However I am surprised to learn that Firefox compiles regular expressions into state machines.  (As someone who used to develop a competing product and is still tangentially involved with it, I am probably still legally prevented from looking at the firefox implementation, so I cannot check myself.)&lt;/p&gt;

&lt;p&gt;The JScript implementation of regular expressions compiles into a bytecode language which is then run through a custom bytecode interpreter.  This interpreter is allowed to do backtracking. This is the usual approach these days for so-called &quot;regular&quot; expressions, because regular expressions are not actually regular anymore.  There is not a 1-1 mapping between a finite state machine and a modern regular expression. Modern regular expressions require at least a stack, which makes them equivalent to something as strong or stronger than push-down automata, not state machines.&lt;/p&gt;

&lt;p&gt;This means that (at least in our implementation, I cannot speak for anyone else&#039;s) you cannot rely on matching being O(N), because of the potential backtracking.  It is certainly possible to build regular expressions which take polynomial time to match and I believe it is possible to build a regular expression which takes exponential time to match.&lt;/p&gt;

&lt;p&gt;Yours is probably not an example of such though.&lt;br /&gt;
&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>I don&#39;t doubt that for typical data the regexp algorithm is O(N), or that it is typically faster than the O(MN) naive solution.  </p>
<p>However I am surprised to learn that Firefox compiles regular expressions into state machines.  (As someone who used to develop a competing product and is still tangentially involved with it, I am probably still legally prevented from looking at the firefox implementation, so I cannot check myself.)</p>
<p>The JScript implementation of regular expressions compiles into a bytecode language which is then run through a custom bytecode interpreter.  This interpreter is allowed to do backtracking. This is the usual approach these days for so-called &quot;regular&quot; expressions, because regular expressions are not actually regular anymore.  There is not a 1-1 mapping between a finite state machine and a modern regular expression. Modern regular expressions require at least a stack, which makes them equivalent to something as strong or stronger than push-down automata, not state machines.</p>
<p>This means that (at least in our implementation, I cannot speak for anyone else&#39;s) you cannot rely on matching being O(N), because of the potential backtracking.  It is certainly possible to build regular expressions which take polynomial time to match and I believe it is possible to build a regular expression which takes exponential time to match.</p>
<p>Yours is probably not an example of such though.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

