Regex match not back-referencing in function

Поиск
Список
Период
Сортировка
От Thom Brown
Тема Regex match not back-referencing in function
Дата
Msg-id CAA-aLv7AXYpoLwohA1=3qyZgbBYUaZyXNSsrDJoHtm9R_W8eXw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Regex match not back-referencing in function  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Regex match not back-referencing in function  (David Johnston <polobo@yahoo.com>)
Список pgsql-general
Hi,

Could someone explain the following behaviour?

SELECT regexp_replace(E'Hello & goodbye ',E'([&])','&#' ||
ascii(E'\\1') || E';\\1');

This returns:

     regexp_replace
------------------------
 Hello \& goodbye
(1 row)

So it matched:

SELECT chr(92);
 chr
-----
 \
(1 row)

But notice that when I append the value it's supposed to have matched
to the end of the replacement value, it shows it should be '&'.

Just to confirm:

SELECT ascii('&');
 ascii
-------
    38
(1 row)

So I'd expect the output of the original statement to be:

     regexp_replace
------------------------
 Hello && goodbye
(1 row)

What am I missing?

--
Thom

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

Предыдущее
От: Dmitriy Igrishin
Дата:
Сообщение: Unambiguous identification of the cluster.
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Regex match not back-referencing in function