<?xml version="1.0" encoding="windows-1252"?>
<node id="1004895" title="Re: Replace the nth occurence" created="2012-11-21 05:56:02" updated="2012-11-21 05:56:02">
<type id="11">
note</type>
<author id="915343">
trizen</author>
<data>
<field name="doctext">
A general solution:
&lt;code&gt;my $nth = 4;
my $str = 'a=&gt;bb=&gt;ccc=&gt;dddd=&gt;eeeee=&gt;ffffff';

while ($str =~ /=&gt;/g) {
    if (--$nth == 0) {
        substr($str, $-[0], $+[0] - $-[0], '~~|~~');
        last;
    }
}
print "$str\n";&lt;/code&gt;</field>
<field name="root_node">
1004836</field>
<field name="parent_node">
1004836</field>
</data>
</node>
