regexp_match()

返回正则表达式匹配项的函数

regexp_match() 是一个系统函数,用于返回与 POSIX 正则表达式匹配的第一个子字符串。

regexp_match() 已在 PostgreSQL 10 中添加。

用法

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

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

regexp_match() 本质上是 regexp_matches() 的简化版本。可以在 PostgreSQL 文档中找到与 regexp_match() 一起使用的标志列表:ARE 嵌入式选项字母

变更历史

示例

regexp_match() 的基本用法示例

postgres=# SELECT regexp_match('foobarboo', '.oo');
 regexp_match
--------------
 {foo}
(1 row)

'g' 标志不能与 regexp_match() 一起使用

postgres=# SELECT regexp_match('foobarboo', '.oo', 'g');
ERROR:  regexp_match does not support the global option
HINT:  Use the regexp_matches function instead.

分类

字符串操作, 系统函数

另请参阅

regexp_matches(), regexp_substr()

反馈

请在此处提交对“regexp_match()”的任何评论、建议或更正。这里