in reply to How to make these reg exp changes?

For the first substitution case, I tried:
if($string=~/(.*?)(\.+)(M+i+)/i) { $first=$1; $change=$2; $len_change=length($change); $third=$3; print $first; print 'O' x $len_change; print $third; print "\n"; }
and it printed:
III...MMMMMOOOOOOOOMMMiiiii
which is correct. Is there a quicker way however?

Replies are listed 'Best First'.
Re^2: How to make these reg exp changes?
by Anonymous Monk on Nov 15, 2009 at 22:51 UTC
    But the thing is that although I change ...MMMiii to OOOMMMiii , at the same time, I must change III...MMMOOO to IIIMMMOOOO which is not covered by the previous reg exp...
    any suggestions?