更新时间:2026-07-03 GMT+08:00
分享

regexp_count1

计算source中从start_position位置开始,匹配指定pattern的子串数。

命令格式

regexp_count1(string <source>, string <pattern>[, bigint <start_position>]) 

参数说明

参数

是否必选

参数类型

说明

source

STRING

待搜索的字符串。

pattern

STRING

正则表达式。pattern为空串时返回报错。

start_position

BIGINT

搜索的开始位置,必须大于0。不指定时默认为1,表示从source的第一个字符开始匹配。

返回值说明

返回BIGINT类型的值。

  • 如果没有匹配成功,返回0。
  • source或pattern值为NULL时,返回NULL。

示例代码

返回4。

select regexp_count1('ab0a1a2b3c', '[0-9]'); 

返回3。

select regexp_count1('ab0a1a2b3c', '[0-9]', 4); 

返回NULL。

select regexp_count1('ab0a1a2b3c', null);

相关文档