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

Home -> Community -> Usenet -> c.d.o.tools -> Re: counting number of times in strings

Re: counting number of times in strings

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: 2000/07/11
Message-ID: <396B2D39.5102@yahoo.com>#1/1

Maurice Samuels wrote:
>
> does anyone out there know of any oracle supplied functions (pl/sql) that
> will count the number of times a character appears in a strings?
> for example,
> string='0011223344'
>
> the function would return 2 if i asked how many times '0' appears in the string.
> thanks in advance
> -maurice
> samuels_at_seas.upenn.edu

A cute trick...

take the difference between

length(string) and
length(replace(string,search_string,null))

HTH

-- 
===========================================
Connor McDonald
http://www.oracledba.co.uk

We are born naked, wet and hungry...then things get worse
Received on Tue Jul 11 2000 - 00:00:00 CDT

Original text of this message

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