Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: I want to know how many times comma(,) appear in string ...
Try this function:
Create or replace function Occurence(aString in varchar2, aPattern in
varchar2)
return number
is
l number;
i integer;
n integer := 1;
c integer := 0;
begin
l := LENGTH(aString);
if aString is null or l<1 then
return 0;
end if;
loop
i := INSTR(aString, aPattern, n);
exit when i=0;
c := c+1;
n := i+1;
end loop;
return c;
end;
Yann.
"ÃÖ»ó¼ø" a écrit :
> 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 - 05:50:27 CDT
![]() |
![]() |