top of page

Count in string in PLSQL with REGEXP_COUNT

  • Writer: Rumesh Aponso (RMAX)
    Rumesh Aponso (RMAX)
  • Nov 5, 2024
  • 1 min read

Updated: Nov 22, 2024

DECLARE
   count_                    NUMBER;
   count_with_ignore_case_   NUMBER;
   data_                     CLOB;
BEGIN
   data_ := 'The REGEXP_LIKE condition uses the input character set to evaluate strings. 
If you specify match_parameter values that conflict, the REGEXP_LIKE condition will use the last value to break the conflict.
If the match_parameter is omitted, the REGEXP_LIKE condition will use the case-sensitivity as determined by the NLS_SORT parameter.';

   count_                  := REGEXP_COUNT(data_, 'the');
   count_with_ignore_case_ := REGEXP_COUNT(LOWER(data_), LOWER('the'));

   Dbms_Output.Put_Line('Exact Count: ' || count_);
   Dbms_Output.Put_Line('  All Count: ' || count_with_ignore_case_);
END;

Output:

ree
ree

Useful Links:

Comments


Copyright © 2025 RMAXOneNote

  • Online CV
  • LinkedIn
  • Youtube
  • GitHub
  • Blogger
bottom of page