You can generalize it for any number of repeated characters too.
while ( my $string = <DATA> ) { $string =~ s/(.)(\1+)/$1.length($1.$2)/ge; print $string; } __DATA__ Balloon bookkeeper Wheeeee!!!
Output:
Bal2o2n bo2k2e2per Whe5!3
In reply to Re: perl search and replace
by thundergnat
in thread perl search and replace
by LeukvoorJ
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |