Re: find out how many times particular character occur in given string.

From: Bob Jones <email_at_me.not>
Date: Thu, 11 Dec 2008 19:48:22 -0600
Message-ID: <Mpj0l.13793$Ws1.1555@nlpi064.nbdc.sbc.com>

"Bob Jones" <email_at_me.not> wrote in message news:noj0l.13792$Ws1.1977_at_nlpi064.nbdc.sbc.com...
>
> "Mladen Gogala" <gogala.mladen_at_gmail.com> wrote in message
> news:ghqqpg$3cl$2_at_solani.org...
>> On Wed, 10 Dec 2008 05:19:20 -0800, Sanjeev wrote:
>>
>>> Dear Gurus,
>>>
>>> I want to find out how many times particular character occur in
>>> given string.
>>> e.g. 'A*B*C*D*E*F' count of '*' is 5
>>> 'A*B*C*D' count of '*' is 3
>>> 'A' count of '*' is 0
>>>
>>> Is there any function available in SQL to find out the above requirement
>>> ?
>>>
>>> Could anyone help me in above?
>>>
>>> Thanking in advance
>>> Sanjeev
>>
>> SQL> select regexp_count('A*B*C*D*E*F','\*') as "Reply for C.D.O.S"
>> 2 from dual;
>>
>> Reply for C.D.O.S
>> -----------------
>> 5
>>
>> Elapsed: 00:00:00.01
>>
>
> Maybe only good for 10g?
>

Correction: 11g

>> You can also do that in Perl:
>>
>> perl -e '$a="A*B*C*D*E*F"; print scalar(split(/\*/,$a))-1,"\n";'
>>
>> SQL is not an ideal tool for the string manipulation.
>
> Yes, let's crank up the Perl engine.
>
Received on Thu Dec 11 2008 - 19:48:22 CST

Original text of this message