REGEXP_SUBSTR
Returns the first fragment of a string that matches a regular expression — as plain text.
Syntax
REGEXP_SUBSTR(<text>, '<pattern>')
REGEXP_SUBSTR(<text>, '<pattern>', <start>, <match number>)
REGEXP_SUBSTR(<text>, '<pattern>', <start>, <match number>, '<flags>')
The simpler sibling of REGEXP_MATCHES: it returns text rather than an array, and if there's no match — NULL, so the table row doesn't disappear from the result. Extra arguments set the position to search from, which match to take and flags such as 'i'. Added in PostgreSQL 15.