REGEXP_EXTRACT
Last updated
Last updated
Finds the first match of the regular expression pattern in string and returns the capturing group number requested.
REGEXP_EXTRACT(string, pattern, group)
string
string
pattern
string
group
numeric
When the group argument is excluded, this function returns the first substring matched by the regular expression pattern in the string.
If the group argument is included, the function finds the first occurrence of the regular expression pattern in the string and returns the capturing group number group.
'1a 2b 14m'
'\d+'
'1'
'document.pdf'
'.([^.]+)$'
'.pdf'
'1a 2b 14m'
''
''
'1a 2b 14m'
'c'
NULL
'1a 2b 14m'
'(1a'
NULL
'1a 2b 14m'
'(\d+)([a-z]+)'
'2'
'a'
'1a 2b 14m'
'(\d+)([a-z]+)'
'1'
'1'
'1a 2b 14m'
'(\d+)([a-z]+)'
'0'
'1a'