Counting Strings

Giganews Newsgroups
Subject: Counting Strings
Posted by:  Mtek (mt…@mtekusa.com)
Date: Wed, 9 Jul 2008

Hi,

We are running 10g r2.  Too bad REGEXP_COUNT does not work.  I need to
count the occurances of a string within a string.

It works from when used in a select from a table:

SELECT LENGTH(c1) - LENGTH(REPLACE(c1, 'Oracle', 'Oracl')) FROM x;

This gives me a result of 4, which is correct.  However, what if in PL/
SQL I need to use it against a variable?

SELECT LENGTH('ABC:DEF:GAB:CDE:GS') -
LENGTH(REPLACE('ABC:DEF:GAB:CDE:GS', ':', 'art')) FROM dual;

I get -8????

Anyone?

Thank you,

John.

Replies