Skip to main content
Counts the number of times a pattern occurs in a string. It returns the number of occurrences of the regular expression pattern in the target string.

Syntax

Parameters

  • str: The string to search in. Supported data type is VARCHAR. If the input is NULL, NULL is returned.
  • pattern: The regular expression pattern to search for. Supported data type is VARCHAR. If the pattern is NULL, NULL is returned.

Return value

Returns an INT representing the count of occurrences. Returns 0 if no matches are found or if the input string is empty.

Examples



Tip This example uses the Local Climatological Data(LCD) dataset featured in the the database Basics Quick Start. You can load the data and try the example yourself.

With table data

keyword

REGEXP_COUNT,REGEXP,COUNT