REGEXP_COUNT

Purpose

This function searches for occurrences of a regular expression pattern in a string and returns the number of times the pattern is found. If the pattern is not present, the value 0 (zero) is returned. Otherwise, the function returns the total count of pattern matches within the string.

Syntax

regexp_instr::=

Usage notes

Example

Copy
SELECT REGEXP_COUNT('Fair fox Flew Far'
  '(?i)fA'
  ) REGEXP_COUNT1,
  REGEXP_COUNT('eeeee! said the dentist',
  'e',
  3
  ) REGEXP_COUNT2;
Result:

REGEXP_COUNT1

REGEXP_COUNT2

2

5