<?xml version="1.0" encoding="windows-1252"?>
<node id="1005036" title="Re: Regexp help" created="2012-11-21 20:23:20" updated="2012-11-21 20:23:20">
<type id="11">
note</type>
<author id="333489">
muba</author>
<data>
<field name="doctext">
&lt;p&gt;First of all, what do you mean by &lt;i&gt;null&lt;/i&gt;? I will assume you mean [doc://undef], but you might as well mean the numerical value 0.&lt;/p&gt;

&lt;p&gt;Secondly, one of Perl's slogan's is &lt;i&gt;There Is More Than One Way To Do It&lt;/i&gt;, or TIMTOWTDI as we say. This applies here as well. There is no &lt;i&gt;the correct way&lt;/i&gt;, there are many.&lt;/p&gt;

&lt;p&gt;My next question, thus, is: what have you tried? Why didn't it work? Did you get any error messages and if you did, which? How did your output not meet your expectations?&lt;/p&gt;

&lt;p&gt;Lastly, a regular expression in the traditional sense ([doc://m|m//]) might not b the most suitable task. What you have is a &lt;c&gt;|&lt;/c&gt; delimited string, so most likely you'll want to [doc://split] on that. Keep in mind that &lt;c&gt;split&lt;/c&gt; takes a regular expression as its first argument, and &lt;c&gt;|&lt;/c&gt; has a special meaning inside regular expression so you'll have to escape that.&lt;/p&gt;

&lt;p&gt;Then you'll want to iterate over the list you get, using something like [doc://map] for example, or if you're uncomfortable with those merits of functional programming, you could do it with a simple [http://perldoc.perl.org/perlsyn.html#Foreach-Loops|foreach] loop over the array.&lt;/p&gt;

&lt;p&gt;This should give you the building blocks you're looking for.&lt;/p&gt;</field>
<field name="root_node">
1005032</field>
<field name="parent_node">
1005032</field>
</data>
</node>
