Answer the question
In order to leave comments, you need to log in
What is the error of using regexp_replace in postgres 12?
Before I give the essence in the form of examples, please DO NOT stick to the meaning, only to the mechanics of the function itself.
So examples.
How to cut out the tags (do not stick to the point, please):
SELECT regexp_replace('foo <a>123</a> bar <a>123</a> baz', '<a>.*?</a>', '', 'g');
-- foo bar baz
SELECT regexp_replace('foo <a X>123</a> bar <a Y>123</a> baz', '<a [XY]>.*?</a>', '', 'g');
-- foo bar baz
SELECT regexp_replace('foo <a X>123</a> bar <a Y>123</a> baz', '<a (X|Y)>.*?</a>', '', 'g');
-- foo baz
Answer the question
In order to leave comments, you need to log in
The answer is found in IRC postgres and documentation.
You need to write like this:
SELECT regexp_replace('foo <a X>123</a> bar <a Y>123</a> baz', '<a (X|Y){1,1}?>.*?</a>', '', 'g');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question