<?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: RegExp In An Anonymous Function</title>
	<atom:link href="http://jacksondunstan.com/articles/341/feed" rel="self" type="application/rss+xml" />
	<link>http://jacksondunstan.com/articles/341</link>
	<description>Mastering AS3</description>
	<lastBuildDate>Mon, 14 May 2012 17:02:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/341/comment-page-1#comment-111</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Mon, 05 Oct 2009 16:25:49 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=341#comment-111</guid>
		<description>This piqued my interest so I tried it out:

&lt;pre lang=&quot;actionscript3&quot;&gt;
const ITERATIONS:int = 5000000;
var i:int;
var before:int = getTimer();
for (i = 0; i &lt; ITERATIONS; ++i)
{
	/^monkey$/.exec(&quot;notmonkey&quot;);
}
trace(&quot;Special Syntax: &quot; + (getTimer()-before));

before = getTimer();
for (i = 0; i &lt; ITERATIONS; ++i)
{
	new RegExp(&quot;^monkey$&quot;).exec(&quot;notmonkey&quot;);
}
trace(&quot;Constructor: &quot; + (getTimer()-before));
&lt;/pre&gt;

And the results:

&lt;pre lang=&quot;text&quot;&gt;
Special Syntax: 8228
Constructor: 8228
&lt;/pre&gt;

So I guess it really is just syntax sugar.</description>
		<content:encoded><![CDATA[<p>This piqued my interest so I tried it out:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">const ITERATIONS<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">5000000</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> before<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>i = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> ITERATIONS<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000066; font-weight: bold;">++</span>i<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #009966; font-style: italic;">/^monkey$/</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">exec</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;notmonkey&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Special Syntax: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">-</span>before<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
before = <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span>i = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&lt;</span> ITERATIONS<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000066; font-weight: bold;">++</span>i<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">RegExp</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;^monkey$&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">exec</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;notmonkey&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Constructor: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">-</span>before<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>And the results:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Special Syntax: 8228
Constructor: 8228</pre></div></div>

<p>So I guess it really is just syntax sugar.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dVyper</title>
		<link>http://jacksondunstan.com/articles/341/comment-page-1#comment-99</link>
		<dc:creator>dVyper</dc:creator>
		<pubDate>Mon, 05 Oct 2009 08:12:22 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=341#comment-99</guid>
		<description>I wonder if anyone has done any speed comparisons between using the RegExp constructor and not using it...</description>
		<content:encoded><![CDATA[<p>I wonder if anyone has done any speed comparisons between using the RegExp constructor and not using it&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/341/comment-page-1#comment-92</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Sat, 03 Oct 2009 03:48:02 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=341#comment-92</guid>
		<description>Good point. If you&#039;re going to use the syntax sugar, you have a constant regular expression anyhow. Thanks for pointing this out.</description>
		<content:encoded><![CDATA[<p>Good point. If you&#8217;re going to use the syntax sugar, you have a constant regular expression anyhow. Thanks for pointing this out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jan</title>
		<link>http://jacksondunstan.com/articles/341/comment-page-1#comment-91</link>
		<dc:creator>Jan</dc:creator>
		<pubDate>Sat, 03 Oct 2009 03:42:59 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=341#comment-91</guid>
		<description>This way very simple and clean:

public static const UPPER : RegExp = /[A-Z]/;
public static const LOWER : RegExp = /[a-z]/;

Usage:

UPPER.test(&quot;Hello world&quot;)</description>
		<content:encoded><![CDATA[<p>This way very simple and clean:</p>
<p>public static const UPPER : RegExp = /[A-Z]/;<br />
public static const LOWER : RegExp = /[a-z]/;</p>
<p>Usage:</p>
<p>UPPER.test(&#8220;Hello world&#8221;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jackson</title>
		<link>http://jacksondunstan.com/articles/341/comment-page-1#comment-90</link>
		<dc:creator>jackson</dc:creator>
		<pubDate>Fri, 02 Oct 2009 15:51:50 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=341#comment-90</guid>
		<description>Whoa. It makes the syntax even weirder, but still a nice workaround so you can use the syntax sugar. Thanks for the tip!</description>
		<content:encoded><![CDATA[<p>Whoa. It makes the syntax even weirder, but still a nice workaround so you can use the syntax sugar. Thanks for the tip!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hanamura</title>
		<link>http://jacksondunstan.com/articles/341/comment-page-1#comment-88</link>
		<dc:creator>hanamura</dc:creator>
		<pubDate>Fri, 02 Oct 2009 11:22:20 +0000</pubDate>
		<guid isPermaLink="false">http://jacksondunstan.com/?p=341#comment-88</guid>
		<description>This also works fine in my environment.

     return (/^monkey$/);</description>
		<content:encoded><![CDATA[<p>This also works fine in my environment.</p>
<p>     return (/^monkey$/);</p>
]]></content:encoded>
	</item>
</channel>
</rss>

