Contents
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
- PostgreSQL 8.3
- added (commit 9eb78bee)
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)
References
- PostgreSQL documentation: Other String Functions