<?xml version="1.0" encoding="windows-1252"?>
<node id="455142" title="Re^2: what is the best way to seperate the digits and strings from variable ?" created="2005-05-09 06:58:55" updated="2005-08-14 00:32:00">
<type id="11">
note</type>
<author id="275605">
dbwiz</author>
<data>
<field name="doctext">
&lt;p&gt;Please, test your code. &lt;/p&gt;
&lt;p&gt;&lt;code&gt;\d*&lt;/code&gt; will match 0 (ZERO) or more digits.&lt;/p&gt;
&lt;p&gt;Thus, it will happily match an empty string at the
beginning of a string like "abc123" and return a 0 length
string. Try it.&lt;/p&gt;
&lt;p&gt;The right expression to use in this case is &lt;code&gt;\d+&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Moreover, a capturing regular expression should
always be used with a test:&lt;/p&gt;
&lt;code&gt;
my $num;
my $variable = "abc123";
if ( $variable =~ /(\d+)/)
{
    $num = $1;
}

&lt;/code&gt;</field>
<field name="root_node">
455137</field>
<field name="parent_node">
455139</field>
</data>
</node>
