Skip to content

REGEXP_COUNT

REGEXP_COUNT(source_string, pattern, position, match_parameter)

Section titled “REGEXP_COUNT(source_string, pattern, position, match_parameter)”
  • source_string: The string in which the pattern will be searched.
  • pattern: The regular expression pattern that is to be matched in the source string.
  • position: Determines where in the source string to begin the search. Default value is 1, which signifies that the search will start from the first character of the string.
  • match_parameter: An optional parameter which allows different types of pattern matching, including case sensitivity and line matching. If this parameter is not provided, the function uses default matching parameters.
SELECT REGEXP_COUNT('Hello World', 'o') AS count_o
FROM dual;
COUNT_O
----------
2

The REGEXP_COUNT function in Oracle is used to count the number of times a pattern occurs in a string. In the provided example, it counts the number of ‘o’ in the string ‘Hello World’ and returns the count as ‘2’.