If you just want to remove them, look at the /s flag to the transliteration operator (tr//). If you want to replace them, use a regular expression substitution with backreferences. It may be something like: s/(\w)\1+/$1\* /g;. That's untested, but it should get you on your way.