Search Postgresql Archives

Re: regexp_replace double quote

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 15, 2016 at 9:27 AM, Михаил <m.nasedkin@xxxxxxxxx> wrote:
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.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux