I have this string:
b'32^"Strings" c32 d32 c32 b32 r8. \break
I want to replace [a-z]
(except r
) with r
and remove '
everywhere outside ".."
. I want to ignore \break
.
Final output should be:
r32^"Strings" r32 r32 r32 r32 r8. \break
The tricky part is sometimes the ".."
and/or \break
may not be present.
For example:
b'32 c32 d32 c32 b32 a32 g32 fis32 d'32 \break
Should be converted to:
r32 r32 r32 r32 r32 r32 r32 r32 r32 \break
A single command would be desirable, but multiple commands are acceptable too.
I tried:
s/^\(.\{-}\)\ze".*$/\=substitute(submatch(1), "[a-z']", 'r', 'g')/
and
s/^.*"\zs\(.*\)/\=substitute(submatch(1), "[a-z]", "r", "g")/
But I am not sure how to handle optional ".."
and \break
.