In PostgreSQL, the regexp_matches()
function returns substrings that match a given POSIX regular expression in a given string. We can specify that all matches are returned or just the first match. If all matches are returned, each is returned in a separate row.
We pass the string as the first argument and the pattern as the second argument. We can also provide a flag as an optional third argument, which determines how the function behaves.
Each returned row is a text array containing the whole matched substring or the substrings matching parenthesised subexpressions of the pattern.
Continue reading