Perhaps a programmatic pattern?
johngg@aleatico:~/perl/Monks$ perl -Mstrict -Mwarnings -E 'say q{}; my $text = <<__EOT__; cat dog cat mouse eel cat housecat catamaran fish __EOT__ my $n = 0; $text =~ s{cat(?{ $n++ })}{$n}g; say $text;' 1 dog 2 mouse eel 3 house4 5amaran fish
I hope this is helpful.
Cheers,
JohnGG
In reply to Re: Perl substitute with the nth match
by johngg
in thread Perl substitute with the nth match
by misterperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |