Re: replace inside regexp_replace

2021-06-22 Thread Oliver Kohll
On Mon, 21 Jun 2021 at 15:09, Francisco Olarte wrote: > Oliver: > > On Mon, Jun 21, 2021 at 3:27 PM Oliver Kohll > wrote: > ... > > My attempt to do that is the regex > > select regexp_replace( > > 'here is [[my text]] to replace and [[some more]]', > > E'\\[\\[(.*?)\\]\\]', > > replace(E'\\1',

Re: replace inside regexp_replace

2021-06-21 Thread David G. Johnston
On Monday, June 21, 2021, Oliver Kohll 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) usin

Re: replace inside regexp_replace

2021-06-21 Thread hubert depesz lubaczewski
On Mon, Jun 21, 2021 at 02:27:22PM +0100, Oliver Kohll wrote: > 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

Re: replace inside regexp_replace

2021-06-21 Thread Francisco Olarte
Oliver: On Mon, Jun 21, 2021 at 3:27 PM Oliver Kohll wrote: ... > 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

replace inside regexp_replace

2021-06-21 Thread Oliver Kohll
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