in reply to In place replace, ignoring between quotes

> I'm sure this is very simply, but my Perl is very weak so I'm not really having much luck.

nope it's not trivial.

But a simplistic solution of 3 phase regexing is to extract and replace all parts within quotes with a safe placeholder (using special characters like '§'), then do your translation and at the end reenter the extracted parts.

Other approaches can be found by searching for "recursive parsing regexes", but IMHO they are overkill in this case.

Cheers Rolf

( addicted to the Perl Programming Language)

update

proof of concept

DB<131> $str=$str0 => " bla0 \"ignore a1\" bla1 \"ignore a2\" bla2" DB<132> $x=0;$extract[$x++]=$& while $str =~ s/"[^"]*"/<$x>/ => "" DB<133> @extract => ("\"ignore a1\"", "\"ignore a2\"") DB<134> $str =~ s/a/A/g => 3 DB<135> $str => " blA0 <0> blA1 <1> blA2" DB<136> $str =~ s/<(\d+)>/$extract[$1]/g => 2 DB<137> $str => " blA0 \"ignore a1\" blA1 \"ignore a2\" blA2"