regexp_split_to_array()

A function for splitting a string to an array using a regular expression

regexp_split_to_array() is a system function for splitting a string into an array using a POSIX regular expression as the delimiter.

regexp_split_to_array() was added in PostgreSQL 8.3.

Usage

regexp_split_to_array ( string text, pattern text [, flags text ] ) → text[]

A list of flags (other than 'g') is available in the PostgreSQL documentation: ARE Embedded-Option Letters.

Change history

Examples

Basic usage example for regexp_split_to_table():

postgres=# SELECT regexp_split_to_array('foo  bar baz', '\s+');
 regexp_split_to_array 
-----------------------
 {foo,bar,baz}
(1 row)

Categories

String manipulation, System function

See also

string_to_array(), string_to_table(), regexp_split_to_table(), split_part()