<?xml version="1.0" encoding="windows-1252"?>
<node id="782138" title="Re^4: How do I quickly strip blank space from the beginning/end of a string?" created="2009-07-21 21:12:57" updated="2009-07-21 21:12:57">
<type id="11">
note</type>
<author id="123017">
blahblahblah</author>
<data>
<field name="doctext">
Good point.  I've tried the 3 methods below:
&lt;code&gt;
if ($x =~ /\s/)
&lt;/code&gt;
and
&lt;code&gt;
if (substr($x, -1) =~ /^\s/
&lt;/code&gt;
and
&lt;code&gt;
if (rindex($x," ") == 0 || rindex($x,"\r") == 0 ||  rindex($x,"\n") == 0 ||  rindex($x,"\t") == 0)
&lt;/code&gt;
The rindex method is much faster on the data that has spaces; otherwise the substr method is the fastest.  Any other good ideas, keeping in mind that the data (I think) won't often contain any trailing spaces?</field>
<field name="root_node">
782077</field>
<field name="parent_node">
782116</field>
</data>
</node>
