The above code finds a repeated character only once i.e. the "o" after "F". If it is repeated again it is being ignored in this case the "o"s after b. How to find the all the repeated characters and have them substituted. Thanksmy $str = "Foooboooobaaar"; while($str =~ /(\w)(\1+)/gi) { print "\nInside while concat_str -- $1 ---- $2 ---> $1.$2"; $str_concat = $1.$2; $str_rep_concat = $1.'*'; $str=~ s/$str_concat/$str_rep_concat/gi; } print "\n$str";
In reply to Replace repeated characters with * by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |