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

Home -> Community -> Usenet -> c.d.o.server -> Re: String function

Re: String function

From: Kalmact <kalmact_at_hotmail.com>
Date: 26 Aug 2003 05:44:35 -0700
Message-ID: <8007e332.0308260444.6280cb9f@posting.google.com>


You can create a function to do something like this

customer_at_ALLDEV1> select (length('THIS IS A STRING') - length(replace('THIS IS A STRING','IS','')))/ length('IS') from dual;

(LENGTH('THISISASTRING')-LENGTH(REPLACE('THISISASTRING','IS','')))/LENGTH('IS')


                                                                      
       2

  1* select (length('THIS IS A STRING') - length(replace('THIS IS A STRING','S','')))/length('S') fr
customer_at_ALLDEV1> /

(LENGTH('THISISASTRING')-LENGTH(REPLACE('THISISASTRING','S','')))/LENGTH('S')


                                                                      
     3

  1* select (length('THIS IS A STRING') - length(replace('THIS IS A STRING','X','')))/length('X') fr
customer_at_ALLDEV1> /

(LENGTH('THISISASTRING')-LENGTH(REPLACE('THISISASTRING','X','')))/LENGTH('X')


                                                                      
     0


Cheers,
Kal
"Max" <massimo.panero_at_ideainformatica.org> wrote in message news:<bifarn$8hvkb$1_at_ID-121437.news.uni-berlin.de>...
> Is there a function that return how many occurrence of a substring are in a
> string?
> Or how can i do by myself?
> Example:
> ST := 'THIS IS A STRING';
> N := XFunction ( ST, 'S' ); // return 3
> N := XFunction ( ST, 'IS' ); // return 2
> N := XFunction ( ST, 'X' ); // return 0
Received on Tue Aug 26 2003 - 07:44:35 CDT

Original text of this message

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