Dave S. wrote:
> Xicheng,
>
> I guess I should be investing my time in learning more about Perl
> instead of sed!
>
> Anyway, just to throw a wrench into the fan, the literal string can
> have escaped quotation marks in it, as in this:
> "Hello \"Mr. Jia\". How are you?"
>
> What do you think about that?
> Can your Perl that rocks handle that, huh?
there are pretty much some standard ways to handle this kind of case,
like:
_______________________________
bash: ~$ echo '
if not ( ( a and b ) or ( c and d ) )
write(output) << "Send receipt\" and sample \"of blood to
rebateshq.com
and expect not to get a reply."
' | perl -0777pe 's/("[^\\"]*(?:\\.[^\\"]*)*")|and/$1 or "&&"/eg'
if not ( ( a && b ) or ( c && d ) )
write(output) << "Send receipt\" and sample \"of blood to
rebateshq.com
and expect not to get a reply."
_______________________________
Just change
"[^"]*"
to
"[^\\"]*(?:\\.[^\\"]*)*"
or change it to
"(?:\\.|[^\\"]*)*"
the latter one is much easier to be understood but less efficient from
regex's application viewpoint.
Good luck,
Xicheng