DB2 Scalar functions - REGEXP_COUNT
The REGEXP_COUNT scalar function returns a count of the number of times that a regular expression pattern is matched in a string.
The schema is SYSIBM.
If the string unit is specified as CODEUNITS16 or OCTETS, and if the string unit of the source string is CODEUNITS32, an error is returned (SQLSTATE 428GC).
For more information, see "String units in built-in functions" in Character strings.
The result of the function is an INTEGER that represents the number of occurrences of the pattern expression within the source string. If the pattern expression is not found and no argument is null, the result is 0.
If any argument of the REGEXP_COUNT function can be null, the result can be null. If any argument is null, the result is the null value.
Count the number of times "Steven" or "Stephen" occurs in the string "Steven Jones and Stephen Smith are the best players".
SELECT REGEXP_COUNT('Steven Jones and Stephen Smith are the best players', 'Ste(v|ph)en') FROM sysibm.sysdummy1