replace inside regexp_replace

Поиск
Список
Период
Сортировка
От Oliver Kohll
Тема replace inside regexp_replace
Дата
Msg-id CAMS=m5+sh7=4jtEGmgxyQ8OfiL=5YM8DUYQN5UxKZBdtotBsNQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: replace inside regexp_replace  (Francisco Olarte <folarte@peoplecall.com>)
Re: replace inside regexp_replace  (hubert depesz lubaczewski <depesz@depesz.com>)
Re: replace inside regexp_replace  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
Hi,

I have some text

'here is [[my text]] to replace and [[some more]]'

which I want to transform to

'here is my_text to replace and some_more'

i.e. wherever there are double square brackets, remove them and replace spaces in the contents with underscores.

My attempt to do that is the regex

select regexp_replace(
'here is [[my text]] to replace and [[some more]]',
E'\\[\\[(.*?)\\]\\]',
replace(E'\\1', ' ', '_'),
'g'
);

which results in

'here is my text to replace and some more'

It half works, i.e. it removes the brackets but doesn't seem to process the inner replace. It's as if the select were just

select regexp_replace(
'here is [[my text]] to replace and [[some more]]',
E'\\[\\[(.*?)\\]\\]',
E'\\1',
'g'
);

I've a feeling I'm missing something fundamental, any idea what?

Thanks
Oliver

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

Предыдущее
От: Brajendra Pratap Singh
Дата:
Сообщение: XX001ERROR: found xmin from before relfrozenxid for pg_authid and pg_database
Следующее
От: Thorsten Schöning
Дата:
Сообщение: How to hash a large amount of data within Postgres?