Re: regexp_replace weirdness amounts to a bug?

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: regexp_replace weirdness amounts to a bug?
Дата
Msg-id 20230816100743.2l5eva7hufoh3hq3@alvherre.pgsql
обсуждение исходный текст
Ответ на regexp_replace weirdness amounts to a bug?  (Erik Rijkers <er@xs4all.nl>)
Список pgsql-hackers
On 2023-Aug-16, Erik Rijkers wrote:

> Hello,
> 
> The following surprised me enough to think it might be a bug:
> (17devel)
> 
> select
>    regexp_replace('Abc Def'
>   , '([a-z]) ([A-Z])'
>   , '\1 ' || lower('\2')  );
> 
> regexp_replace
> ----------------
>  Abc Def

What's happening here is that the lower() is applying to the literal \2,
and the expansion of \2 to 'D' occurs afterwards, when lower() has
already executed.  Note this other example, where the literal part of
the replacement string is correctly lowercased:

select
   regexp_replace('Abc Def'
  , '([a-z]) ([A-Z])'
  , '\1 ' || lower('D\2D'));
 regexp_replace 
────────────────
 Abc dDdef
(1 fila)

I don't know how to achieve what you want.

-- 
Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/
#error "Operator lives in the wrong universe"
  ("Use of cookies in real-time system development", M. Gleixner, M. Mc Guire)



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

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: Re: pg_logical_emit_message() misses a XLogFlush()
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: cataloguing NOT NULL constraints