The REGEXP_COUNT function is used to count the number of matches of a specific regular expression in a string. It receives two parameters: string and pattern, and returns the number of matches. If there is no match, 0 is returned. Other uses include checking for a match, extracting subgroups of a match, and replacing matches using the REPLACE() function.
REGEXP_COUNT Usage in Oracle
The REGEXP_COUNT function is used to count the number of matches of a specific regular expression in a string.
Syntax:
<code>REGEXP_COUNT(string, pattern)</code>
Parameters:
Return value:
The number of times the regular expression is matched in the string. If there is no match, 0 is returned.
Example:
<code class="sql">SELECT REGEXP_COUNT('hello world', 'o') FROM dual;</code>
Output:
<code>2</code>
Explanation: There are 2 characters "o" in the string "hello world" matching the regular expression "o".
Other uses:
The REGEXP_COUNT function can also be used:
SUBSTR()
function in conjunction with the REGEXP_COUNT function to extract specific subgroups of matches. REPLACE()
function together with the REGEXP_COUNT function to replace specific matches in a string based on a regular expression. The above is the detailed content of regr_count usage in oracle. For more information, please follow other related articles on the PHP Chinese website!