Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Applies to:
Databricks SQL
Databricks Runtime 11.3 LTS and above
Returns the number of times str matches the regexp pattern.
Syntax
regexp_count( str, regexp )
Arguments
str: ASTRINGexpression to be matched.regexp: ASTRINGexpression with a pattern.
Returns
An INTEGER.
The regexp string must be a Java regular expression.
String literals are unescaped. For example, to match '\abc', a regular expression for regexp can be '^\\abc$'.
In case of a malformed regexp the function returns an INVALID_PARAMETER_VALUE error.
If either argument is NULL, the result is NULL.
Examples
> SELECT regexp_count('Steven Jones and Stephen Smith are the best players', 'Ste(v|ph)en');
2
> SELECT regexp_count('Mary had a little lamb', 'Ste(v|ph)en');
0
> SELECT regexp_count(NULL, 'Ste(v|ph)en');
NULL
> SELECT regexp_instr('Mary had a little lamb', NULL);
NULL