Here is a different way using progressive matching and the \G assertion to continue matching from that point. TIMTOWTDI
tachyon
my $nth = 3; my $rep = 1; my $chr = 'e'; my $str = "Terence and Philip are sweet"; $str =~ m/$chr/gc for (1..$nth); # eat up first $nth "$chr"s $str =~ s/\G(.*?)$chr/$1$rep/g; # replace the rest print $str;
In reply to Re: Replacing a given character starting with the xth occurence in a string
by tachyon
in thread Replacing a given character starting with the xth occurence in a string
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |