What does the PostgreSQL function regexp_match do?
It searches a string for a pattern using a regular expression and returns the first substring that matches as a text array.
Click to reveal answer
beginner
How does regexp_replace work in PostgreSQL?
It searches a string for a pattern using a regular expression and replaces the first match (by default) with a specified replacement string. Use the 'g' flag to replace all occurrences.
Click to reveal answer
intermediate
What is the return type of regexp_match in PostgreSQL?
It returns a text array containing the matched substring(s). If no match is found, it returns NULL.
Click to reveal answer
intermediate
How can you replace only the first match of a pattern using regexp_replace?
regexp_replace replaces only the first match by default (no 'g' flag). You can also specify the occurrence parameter as 1.
Click to reveal answer
beginner
Give an example of using regexp_match to extract the first word from a string.