in reply to Re^4: How to make these reg exp changes?
in thread How to make these reg exp changes?
You told us that if the "." is not the first character, one should look back. Are you saying that's wrong?
If you actually want to look to the other side of the adjacent Ms,
perl -wle' my %neg = ( O => "I", I => "O" ); $_ = "III...MMMMMOOOO....MMMIIII"; print; s/([IO])(M+)(\.+)/ $1.$2.( $neg{$1} x length($3) ) /eg; s/(\.+)(?=M+([IO]))/ $neg{$2} x length($1) /eg; print; '
|
---|