I'm trying to remove everything between two captions in postgres:
regexp_replace(text, 'caption1:[\S\s\n\r]+?:', '', 'ig') AS text
But I get this error:
ERROR: invalid regular expression: invalid escape \ sequence
SQL state: 2201B
It looks like it doesn't allow me to match with \S (any non-whitespace character)
Example text:
Lorem ipsum
Caption1:
I want this text to be removed.
And this line too.
Caption2:
Consectetuer adipiscing elit.
It should become:
Lorem ipsum
Consectetuer adipiscing elit.