Hi!
I need to escape double quotes only:
test=# select regexp_replace('"""{Performer,"Boomwacker ""a""
Recording""}"""', '([^"])"{2}([^"])', '\1\"\2', 'g');
regexp_replace
-------------------------------------------------
"""{Performer,"Boomwacker \"a"" Recording\"}"""
What is the goal you are trying to accomplish. Its possible to do what you ask but only if no other solution is feasible.
This is unexpected result.
But when added one symbol to ""a"" the result is right:
test=# select regexp_replace('"""{Performer,"Boomwacker ""a1""
Recording""}"""', '([^"])"{2}([^"])', '\1\"\2', 'g');
regexp_replace
--------------------------------------------------
"""{Performer,"Boomwacker \"a1\" Recording\"}"""
<
([^"])"{2}([^"])> on < ""a""> consumes < ""a> leaving <""> which doesn't match your pattern since there is nothing before the double-quote to satisfy the [^"]See depesz's simultaneous post for the solution using look-ahead.
David J.