Re: regexp_replace double quote

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: regexp_replace double quote
Дата
Msg-id CAKFQuwbqAJi2-Ge0-UCcde4oTe3Z=WXDu0kKj-VxpXRdWah7Gw@mail.gmail.com
обсуждение исходный текст
Ответ на regexp_replace double quote  (Михаил <m.nasedkin@gmail.com>)
Список pgsql-general
On Mon, Aug 15, 2016 at 9:27 AM, Михаил <m.nasedkin@gmail.com> 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.

В списке pgsql-general по дате отправления:

Предыдущее
От: hubert depesz lubaczewski
Дата:
Сообщение: Re: regexp_replace double quote
Следующее
От: Ioana Danes
Дата:
Сообщение: ERROR: MultiXactId XXXXX has not been created yet -- apparent wraparound