<?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: ActionScript trim function</title>
	<atom:link href="http://www.twisty.com/bandwagon/archives/2007/07/23/162642/feed" rel="self" type="application/rss+xml" />
	<link>http://www.twisty.com/bandwagon/archives/2007/07/23/162642</link>
	<description>Hitch your wagon to a chicken</description>
	<lastBuildDate>Thu, 15 Jul 2010 13:35:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Aaron</title>
		<link>http://www.twisty.com/bandwagon/archives/2007/07/23/162642/comment-page-1#comment-175594</link>
		<dc:creator>Aaron</dc:creator>
		<pubDate>Thu, 21 Jan 2010 20:40:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.twisty.com/bandwagon/archives/2007/07/23/162642#comment-175594</guid>
		<description>&lt;p&gt;This is by far the easiest trim method:&lt;/p&gt;

&lt;p&gt;function trim(str:String) {
    return str.replace(/^s/, &quot;&quot;).replace(/s$/, &quot;&quot;);
}&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>This is by far the easiest trim method:</p>

<p>function trim(str:String) {
    return str.replace(/^s/, &#8220;&#8221;).replace(/s$/, &#8220;&#8221;);
}</p>]]></content:encoded>
	</item>
	<item>
		<title>By: anonymous</title>
		<link>http://www.twisty.com/bandwagon/archives/2007/07/23/162642/comment-page-1#comment-173292</link>
		<dc:creator>anonymous</dc:creator>
		<pubDate>Wed, 07 Oct 2009 13:31:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.twisty.com/bandwagon/archives/2007/07/23/162642#comment-173292</guid>
		<description>&lt;p&gt;corrected as and works well as ...
myString.replace(/^\s+&#124;\s+$/g, &#039;&#039;);&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>corrected as and works well as &#8230;
myString.replace(/^\s+|\s+$/g, &#8221;);</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Satish</title>
		<link>http://www.twisty.com/bandwagon/archives/2007/07/23/162642/comment-page-1#comment-163764</link>
		<dc:creator>Satish</dc:creator>
		<pubDate>Wed, 13 May 2009 10:33:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.twisty.com/bandwagon/archives/2007/07/23/162642#comment-163764</guid>
		<description>&lt;p&gt;Thanks!! You saved my time.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks!! You saved my time.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Eduardo Vaz de Mello</title>
		<link>http://www.twisty.com/bandwagon/archives/2007/07/23/162642/comment-page-1#comment-161128</link>
		<dc:creator>Eduardo Vaz de Mello</dc:creator>
		<pubDate>Sat, 18 Apr 2009 19:20:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.twisty.com/bandwagon/archives/2007/07/23/162642#comment-161128</guid>
		<description>&lt;p&gt;Thanks for this, yours worked, the second didn&#039;t.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks for this, yours worked, the second didn&#8217;t.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://www.twisty.com/bandwagon/archives/2007/07/23/162642/comment-page-1#comment-159775</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Fri, 10 Apr 2009 08:47:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.twisty.com/bandwagon/archives/2007/07/23/162642#comment-159775</guid>
		<description>&lt;p&gt;Re #17&lt;/p&gt;

&lt;p&gt;Hi Anthony, that looks like a good option. It&#039;s worth remembering, though, that support for regular expressions only appears in ActionScript 3.0.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Re #17</p>

<p>Hi Anthony, that looks like a good option. It&#8217;s worth remembering, though, that support for regular expressions only appears in ActionScript 3.0.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Anthony Sapien</title>
		<link>http://www.twisty.com/bandwagon/archives/2007/07/23/162642/comment-page-1#comment-154868</link>
		<dc:creator>Anthony Sapien</dc:creator>
		<pubDate>Mon, 09 Mar 2009 21:43:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.twisty.com/bandwagon/archives/2007/07/23/162642#comment-154868</guid>
		<description>&lt;p&gt;Here&#039;s a lightweight regular expression to do it:
myString = myString.replace(/^s+&#124;s+$/g, &#039;&#039;);&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Here&#8217;s a lightweight regular expression to do it:
myString = myString.replace(/^s+|s+$/g, &#8221;);</p>]]></content:encoded>
	</item>
	<item>
		<title>By: AMeen</title>
		<link>http://www.twisty.com/bandwagon/archives/2007/07/23/162642/comment-page-1#comment-149981</link>
		<dc:creator>AMeen</dc:creator>
		<pubDate>Wed, 04 Feb 2009 05:23:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.twisty.com/bandwagon/archives/2007/07/23/162642#comment-149981</guid>
		<description>&lt;p&gt;Thank you very much for this code! saved me time!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thank you very much for this code! saved me time!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Brayshaw</title>
		<link>http://www.twisty.com/bandwagon/archives/2007/07/23/162642/comment-page-1#comment-149322</link>
		<dc:creator>Tim Brayshaw</dc:creator>
		<pubDate>Fri, 30 Jan 2009 15:34:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.twisty.com/bandwagon/archives/2007/07/23/162642#comment-149322</guid>
		<description>&lt;p&gt;Re #13, #14.&lt;/p&gt;

&lt;p&gt;Hi Bryan, thanks for posting. I took the liberty of re-formatting your post that the weblog software mangled. Hopefully it looks like you intended?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Re #13, #14.</p>

<p>Hi Bryan, thanks for posting. I took the liberty of re-formatting your post that the weblog software mangled. Hopefully it looks like you intended?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan Elliott</title>
		<link>http://www.twisty.com/bandwagon/archives/2007/07/23/162642/comment-page-1#comment-149316</link>
		<dc:creator>Bryan Elliott</dc:creator>
		<pubDate>Fri, 30 Jan 2009 15:08:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.twisty.com/bandwagon/archives/2007/07/23/162642#comment-149316</guid>
		<description>&lt;p&gt;Huh.  Sorry about the formatting...&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Huh.  Sorry about the formatting&#8230;</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Bryan Elliott</title>
		<link>http://www.twisty.com/bandwagon/archives/2007/07/23/162642/comment-page-1#comment-149315</link>
		<dc:creator>Bryan Elliott</dc:creator>
		<pubDate>Fri, 30 Jan 2009 15:08:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.twisty.com/bandwagon/archives/2007/07/23/162642#comment-149315</guid>
		<description>&lt;p&gt;A few quick mods:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I find it much more convenient in ECMAScript to have trim overloaded on the String prototype, as it&#039;s unwaveringly applied to strings.&lt;/li&gt;
&lt;li&gt;running a substr on each loop is relatively slow.  It&#039;s harder, but faster, to just keep track of position.&lt;/li&gt;
&lt;li&gt;I&#039;ve added a way to create the charcodes as needed, so you can, say, strip the &#039;/&#039;s off a pathname if you need to.&lt;/li&gt;
&lt;/ol&gt;

&lt;pre&gt;String.prototype.trim = function (strip):String {
        if (!!strip)
            strip = &quot; \t\r\n&quot;;
        var 
            codes = {},
            i,
            start=0,
            len=this.length;
        for (i=0; i&lt;strip.length; i++)
            codes[strip.charCodeAt(i)]=1;
    while(codes[this.charCodeAt(start)]==1) 
        start++;
    len-=start;
    while(codes[this.charCodeAt(start+len-1)]==1)
        len--;
    return this.substr(start, len);
}&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<p>A few quick mods:</p>

<ol>
<li>I find it much more convenient in ECMAScript to have trim overloaded on the String prototype, as it&#8217;s unwaveringly applied to strings.</li>
<li>running a substr on each loop is relatively slow.  It&#8217;s harder, but faster, to just keep track of position.</li>
<li>I&#8217;ve added a way to create the charcodes as needed, so you can, say, strip the &#8216;/&#8217;s off a pathname if you need to.</li>
</ol>

<pre>String.prototype.trim = function (strip):String {
        if (!!strip)
            strip = " \t\r\n";
        var 
            codes = {},
            i,
            start=0,
            len=this.length;
        for (i=0; i&lt;strip.length; i++)
            codes[strip.charCodeAt(i)]=1;
    while(codes[this.charCodeAt(start)]==1) 
        start++;
    len-=start;
    while(codes[this.charCodeAt(start+len-1)]==1)
        len--;
    return this.substr(start, len);
}</pre>]]></content:encoded>
	</item>
</channel>
</rss>
