<?xml version="1.0" encoding="windows-1252"?>
<node id="1004848" title="Re: Replace the nth occurence" created="2012-11-21 01:02:20" updated="2012-11-21 01:02:20">
<type id="11">
note</type>
<author id="634253">
AnomalousMonk</author>
<data>
<field name="doctext">
&lt;p&gt;
Another approach (\K available with 5.10+):
&lt;/P&gt;

&lt;c&gt;
&gt;perl -wMstrict -le
"my $nth = 4;
 my $str = 'a,bb,ccc,dddd,eeeee,ffffff';
 ;;
 --$nth;
 $str =~ s{ (?: , [^,]*){$nth} \K , }{|}xms;
 print qq{'$str'};
"
'a,bb,ccc,dddd|eeeee,ffffff'
&lt;/C&gt;
</field>
<field name="root_node">
1004836</field>
<field name="parent_node">
1004836</field>
</data>
</node>
