regexp_extract_all() function

The regexp_extract_all() function returns, in a varchar or nvarchar array, all matching text items.

Syntax

The regexp_extract_all() function has the following syntax:
array(varchar) = regexp_extract_all(varchar input, varchar pattern 
[, int start_pos] [, varchar flags]);
array(nvarchar) = regexp_extract_all(nvarchar input, nvarchar pattern 
[, int start_pos] [, varchar flags]);

The input value specifies the varchar or nvarchar value against which the regular expression is processed.

The pattern value specifies the regular expression. For a description of how to specify Perl compatible regular expression (PCRE) patterns for Unicode data, see any general PCRE documentation or web sources.

The start_pos value specifies the character position at which to start the extract. The default is 1.

For a description of the flags value, see flags argument.

Returns

The function returns all matching text items.

Example

select array_combine(regexp_extract_all('Steven .Stephen is the best 
player','Ste(v|ph)en'),'|'); 
 ARRAY_COMBINE
----------------
 Steven|Stephen
(1 row)