Re: replace inside regexp_replace - Mailing list pgsql-general

From David G. Johnston
Subject Re: replace inside regexp_replace
Date
Msg-id CAKFQuwYXL7WUmALmrM7T=-gKJinc9NR9j04U7Wm-YwGvPxfmTw@mail.gmail.com
Whole thread Raw
In response to replace inside regexp_replace  (Oliver Kohll <oliver@agilechilli.com>)
List pgsql-general
On Monday, June 21, 2021, Oliver Kohll <oliver@agilechilli.com> wrote:

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

Side note, you seldom want to use “E” (escape) string literals with regexes (or in general really) using just the simple literal syntax removes the need for double-backslashing.

David J. 

pgsql-general by date:

Previous
From: hubert depesz lubaczewski
Date:
Subject: Re: replace inside regexp_replace
Next
From: Ron
Date:
Subject: Re: How to automatically delete idle client connections?