Hi i want to replace characters in String with their number of occurrences.
String is "aaaadddyyyyccccaaaa"
So it should output a4d3y4c4a4.
$ echo 'aaaadddyyyyccccaaaa' | perl -pe 's/(.)\1*/$1.length($&)/ge' a4d3y4c4a4
(.)\1*any character followed by any number of repeats
$1.length($&)captured character and length of entire match
emodifier allows expression in replacement section