in reply to How to make these reg exp changes?

s/(.)(\.+)/$1 x (1+length $2)/seg;

For example,

$ perl -wle' $_ = "III...MMMMMOOOO....MMMIIIII"; print; s/(.)(\.+)/$1 x (1+length $2)/seg; print; ' III...MMMMMOOOO....MMMIIIII IIIIIIMMMMMOOOOOOOOMMMIIIII

Update: Oops, this window must have been open a while. keszler already gave basically the same answer a while ago. As punishment, I'll give an alternative that might be faster for short strings:

$ perl -wle' $_ = "III...MMMMMOOOO....MMMIIIII"; print; 1 while s/(.)(\.)/$1$1/sg; print; ' III...MMMMMOOOO....MMMIIIII IIIIIIMMMMMOOOOOOOOMMMIIIII