Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: I want to know how many times comma(,) appear in string ...

Re: I want to know how many times comma(,) appear in string ...

From: Your Name <Your.Name_at_icl.com>
Date: Mon, 27 Sep 1999 15:18:19 +0100
Message-ID: <37ef7a19.0@145.227.194.253>


Yann Chevriaux solution is ok and probably works fine but there is a much simpler way

Create or replace Function Num_Occurences(vString in varchar2, vSearchString in varchar2)
 return number as
  nNum number := 0;
begin
  nNum := length(vString) - length(replace(vString, vSearchString,''));   return nNum;
end;

SQL> select num_occurences('A,B,C,D,E,F',',') from dual;

NUM_OCCURENCES('A,B,C,D,E,F',',')


                                5

HTH Mark

ÃÖ»ó¼ø <topgun_at_freeway.co.kr> wrote in message news:twFH3.606$Lg2.27813_at_news2.bora.net...
> I want to know the count of the string or character
>
> as follows .
>
> Given,
> ls_string = '1253,5678,ascd,!@#er, 5896, @@@;';
>
>
> How many times appear comma(,) in the string 'ls_string' ?
>
> The result : The comma(,) appears five times in the 'ls_string' .
>
> Is there any function or other way to resolve this problem ?
>
> We use Oracle 7.3.3.3.
>
> Thanks in Advance .
>
>
>
Received on Mon Sep 27 1999 - 09:18:19 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US