regexp_split_to_array()

一个使用正则表达式将字符串拆分为数组的函数

regexp_split_to_array() 是一个系统函数,它使用 POSIX 正则表达式作为分隔符将字符串拆分为一个数组。

regexp_split_to_array()PostgreSQL 8.3 中被添加。

用法

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

命名参数从 PostgreSQL 18 开始可用。

除了 'g' 之外的其他标志列表可以在 PostgreSQL 文档中找到:ARE 嵌入式选项字母

变更历史

示例

regexp_split_to_table() 的基本用法示例

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

分类

数组, 字符串操作, 系统函数

另请参阅

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

反馈

有关“regexp_split_to_array()”的任何评论、建议或更正,请在此处提交。