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_count::=
Usage notes
- For more details and examples on regular expression, see Regular expressions.
-
The optional parameter
start_positiondefines from which position the search should begin (default value is 1). -
REGEXP_COUNT(string, pattern)is similar toREGEXP_COUNT(string, pattern, 1). -
See also functions REGEXP_INSTR, REGEXP_REPLACE, REGEXP_SUBSTR, and the predicate [NOT] REGEXP_LIKE.
Example
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 |