One way
my $nth = 3; my $rep = 1; my $chr = 'e'; my $i = 1; $_ = "Terence and Philip are sweet"; s/($chr)/$i++<$nth?$1:$rep/eg; print;
In reply to Re: Replacing a given character starting with the xth occurence in a string
by quent
in thread Replacing a given character starting with the xth occurence in a string
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |