相关文章推荐
慷慨大方的火腿肠  ·  PHP ...·  10 月前    · 
俊秀的勺子  ·  Mac ...·  1 年前    · 
痴情的油条  ·  Selenium关闭INFO:CONSOLE ...·  1 年前    · 

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft Edge More info about Internet Explorer and Microsoft Edge

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 11.2 and above

Returns the number of times str matches the regexp pattern.

Syntax

regexp_count( str, regexp )

Arguments

  • str: A STRING expression to be matched.
  • regexp: A STRING expression 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');
    > SELECT regexp_count('Mary had a little lamb', 'Ste(v|ph)en');
    > SELECT regexp_count(NULL, 'Ste(v|ph)en');
    > SELECT regexp_instr('Mary had a little lamb', NULL);
    
    
  • ilike operator
  • like operator
  • regexp operator
  • regexp_extract_all function
  • regexp_instr function
  • regexp_replace function
  • regexp_substr function
  • rlike operator
  • split function
  •