my $x = 3; my $chr = 'e'; my $newchr = '1'; my $str = "Terence and Philip are sweet!\n"; print $str; $x--; 1 while ($str =~ s/(([^$chr]*$chr){$x}([^$chr]*))$chr/$1$newchr/g); print $str;
In reply to Re: Replacing a given character starting with the xth occurence in a string
by sachmet
in thread Replacing a given character starting with the xth occurence in a string
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |