How to search occurance of a character in a string

for example in a word Mississippi, find the frequency of character S. it should be 4 as it contains four s.
what is a code.

Hi shri vas,
data: result type match_result_tab,
       w_result type LINE OF  match_result_tab,
       num type c.
FIND ALL OCCURRENCES OF 's' in 'Mississippi' results result.
loop at result INTO w_result.
   num = num + 1.
endloop.
WRITE num.
Regards,
Seshu

Similar Messages

  • How to search for a particular word in a string?

    How to search for a particular word in a string?
    thanks for your help....

    This works fine.
    public class Foo {
        public static void main(String[] args) {
        String s = "Now is the time for all good...";
        String s2 = "the time";
        System.out.println(s.contains(s2));
        System.out.println(s.contains("for al"));
        System.out.println(s.contains("not here"));
    }output:true
    true
    falseYou must have something else wrong in your code.
    JJ

  • How to search for a particular pattern in a string

    Hi,

    Hi ,
    How to search for a particular pattern in a string?
    I heard about java.util.regex; and used it in my jsp program.
    Program I used:
    <% page import="java.util.regex"%>
    <% boolean b=Pattern.matches("hello world","hello");
    out.println(b);%>
    I run this program using netbeans and am getting the following error message.
    "Cannot find the symbol : class regex"
    "Cannot find the symbol : variable Pattern "
    How to correct the error?

  • How we can find the last character in a string(Urgent Plz!)

    Gurus!
    How we can find the last character in a string.
    e.g i have a string say "Str" with value "10-01".
    Now i want to find the last character in "Str" i.e "ONE=1".
    i am using Oracle developer 6i with Oracle 8i(1.7).
    Plz help!
    Many thanks!

    Use the substr() and length() functions -
    x := '10-01';
    y := substr(x, length(x));

  • Count the occurance of a character in a string

    What is the function to count the occurance of a character in a string.
    like 'test test1 test2 test3' with in this string there are 3 white spaces.
    instr will give the first one, replace will change the all... and what's for the occurance (number of white spaces, which is 3 in this case) count
    Message was edited by:
    gladnn

    SQL> var a varchar2(25)
    SQL> exec :a := 'gghhhh999jjjj'
    &nbsp
    PL/SQL procedure successfully completed.
    &nbsp
    SQL> select length(:a) - nvl(length(replace(:a,'h','')),0) from dual;
    &nbsp
    LENGTH(:A)-NVL(LENGTH(REPLACE(:A,'H','')),0)
                                               4Rgds.

  • How to find out the repeated character in a string value?

    Dear People,
    I want to trace out the names where a character occured more than once.for ex, i need o/p as
    ENAME
    ALLEN
    TURNER
    ADAMS
    In which all the above name consists of repeated characters.
    I use Oracle 10g and i tried using REGEXP say for ex,
    SELECT ENAME FROM EMP WHERE REGEXP_LIKE(ENAME,'L{2}');
    ENAME
    ALLEN
    MILLERbut this works only for single character.how to specify condition for any character?.pls suggest me.
    With Regards
    VIDS

    Here is one way you can use from version 10 upwards:
    SQL> with emp as
      2  ( select 7369 empno, 'SMITH' ename, 'CLERK' job, 7902 mgr, date '1980-12-17' hiredate, 800 sal, NULL comm, 20 deptno from dual union all
      3    select 7499, 'ALLEN', 'SALESMAN', 7698, date '1981-02-20', 1600, 300, 30 from dual union all
      4    select 7521, 'WARD', 'SALESMAN', 7698, date '1981-02-22', 1250, 500, 30 from dual union all
      5    select 7566, 'JONES', 'MANAGER', 7839, date '1981-04-02', 2975, NULL, 20 from dual union all
      6    select 7654, 'MARTIN', 'SALESMAN', 7698, date '1981-09-28', 1250, 1400, 30 from dual union all
      7    select 7698, 'BLAKE', 'MANAGER', 7839, date '1981-05-01', 2850, NULL, 30 from dual union all
      8    select 7782, 'CLARK', 'MANAGER', 7839, date '1981-06-09', 2450, NULL, 10 from dual union all
      9    select 7788, 'SCOTT', 'ANALYST', 7566, date '1982-12-09', 3000, NULL, 20 from dual union all
    10    select 7839, 'KING', 'PRESIDENT', NULL, date '1981-11-17', 5000, NULL, 10 from dual union all
    11    select 7844, 'TURNER', 'SALESMAN', 7698, date '1981-09-08', 1500, 0, 30 from dual union all
    12    select 7876, 'ADAMS', 'CLERK', 7788, date '1983-01-12', 1100, NULL, 20 from dual union all
    13    select 7900, 'JAMES', 'CLERK', 7698, date '1981-12-03', 950, NULL, 30 from dual union all
    14    select 7902, 'FORD', 'ANALYST', 7566, date '1981-12-03', 3000, NULL, 20 from dual union all
    15    select 7934, 'MILLER', 'CLERK', 7782, date '1982-01-23', 1300, NULL, 10 from dual
    16  )
    17  select ename
    18       , e
    19       , count(*)
    20    from ( select ename
    21                , e
    22             from emp
    23            model
    24                  return updated rows
    25                  partition by (ename)
    26                  dimension by (0 i)
    27                  measures (ename e)
    28                  ( e[for i from 1 to length(e[0]) increment 1] = substr(e[0],cv(i),1)
    29                  )
    30         )
    31   group by ename
    32       , e
    33  having count(*) > 1
    34  /
    ENAME  E        COUNT(*)
    SCOTT  T               2
    MILLER L               2
    ADAMS  A               2
    ALLEN  L               2
    TURNER R               2
    5 rows selected.Regards,
    Rob.

  • Function in oracle to find number of occurances of a character in a string

    hi,
    is there any function in oracle to find the number of ocurrances of a character in a string ?
    or is there any simple way of doing the same, rather than writting many lines of code as my program is already very complex.
    Maria

    Hi Maria,
    I don't know of such a function in Oracle, but maybe you could use this:
    length(search_string) - length(replace(search_string, character_to_be_found))
    For example: select length('Hello') - length ( replace('Hello', 'l')) from dual;
    Hope this is what you're looking for
    Danny

  • How to get a set of character within a string?

    Hi,
    I need to cut a set of character within a string. I have tried everthing but I need help.
    Example.
    Database Version 11.2.0.3
    create table tst_string (message varchar2(600));
    insert into tst_string values ('ANR0166I Inventory file expiration finished processing for node OSOGBO, filespace OSOGBO\SystemState, copygroup BACKUP and object type GROUP BASE with processing statistics: examined 43, deleted 43, retrying 0, and failed 0. (SESSION: 1506, PROCESS: 2)');
    insert into  tst_string values ('ANE4175I Starting Full VM restore of VMware Virtual Machine ''mfujiwara'' target node name=''VC1_DC1'', data mover node name=''VC1_DC1_DM3''  (SESSION: 3780)');
    commit;
    select * from tst_string;
    MESSAGE
    ANR0166I Inventory file expiration finished processing for node OSOGBO, filespace OSOGBO\SystemState, copygroup BACKUP and object type GROUP BASE with processing statistics: examined 43, deleted 43, retrying 0, and failed 0. (SESSION: 1506, PROCESS: 2)
    ANE4175I Starting Full VM restore of VMware Virtual Machine 'mfujiwara' target node name='VC1_DC1', data mover node name='VC1_DC1_DM3'  (SESSION: 3780)
    ## I want get
    # From first line following values:
    node OSOGBO
    filespace OSOGBO\SystemState
    examined 43
    deleted 43
    retrying 0
    failed 0
    # From second line
    mfujiwara
    VC1_DC1
    VC1_DC1_DM3Any help can be useful...
    Thanks in advance.

    Hi Frank,
    It looks like message can be seen as delimited lsit of sub-messages, where a number of different characters (perhaps ',' amd ':') may serve as delimiters. Each sub-message may or consist (entirely or in part) of something you want to display.Yes. In my first case where is "ANR0166I" I want get the characteres before "," (e.g "OSOGBO," I want get "OSOGBO") excluding "(SESSION: 1506, PROCESS: 2)"
    Would a user-define PL/SQL function be okay for you?Yes.. no problem.
    I'm not good with shell script, but will try show what I want using SHELL commands:
    See this example:
    ### I create a file named "tst_string"
    $ vi tst_string
    ANR0166I Inventory file expiration finished processing for node OSOGBO, filespace OSOGBO\SystemState\NULL\System State\SystemState, copygroup BACKUP and object type GROUP BASE with processing statistics: examined 43, deleted 43, retrying 0, and failed 0. (SESSION: 1506, PROCESS: 2)
    ## So I used a function sed to get my desired values. The command bellow is poor, but My point is the result.
    $ cat tst_string | sed 's/ANR0166I.*node //g' | sed 's/, filespace//g' | sed 's/, copygroup BACKUP and object type GROUP BASE with processing statistics: //g' | sed 's/. (SESSION.*//g' | sed 's/, deleted//g' | sed 's/, retrying//g' | sed 's/, and failed//g'
    OSOGBO OSOGBO\SystemState\NULL\System State\SystemState 43 43 0 0The result was:
    NODE     FILESPACE                              Examined     Deleted     Retrying        Failed      
    OSOGBO      OSOGBO\SystemState\NULL\System State\SystemState     43           43      0           0I will go check the links wich you mentioned.
    Thanks

  • How to search for a number located anywhere in string

    I am trying to search a string for a number (integer or float) without knowing its index in the string and to extract it - whether in numeric or string format.  e.g. "the number 52.63 appears in this string"; I want to extract/identify "52.63"
    The functions I come across seem to expect the index to be known or the number to be at index 0.  How can I achieve this?
    Best regards.
    Kenoss
    Solved!
    Go to Solution.

    If you are about to dive into the 'wonderfull world of Regular Expression' don't miss this (regular-expressions.info) site.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • How can you determine if a character in a string is numeric or alphabetic?

    Hello all,
    I've been trying this one for awhile now, and can't find any way to do it.
    I am reading a character string out of a text file. The string is a number. I need to convert that number to it's decimal equivalent -- this is not a problem, I can do this easily.
    The problem comes in when I'm reading the string from the text file. I want to be able to be sure that they didn't have a typo and insert an alphabetic character into the number. For example, typing 50o instead of 500. If I convert this example, I will read 50. I want it to flag an error instead, but I cannot figure out how to read the string and determine if there are alphabetic and numeric characters in the string I'm
    reading.
    Any help would be greatly appreciated.
    Dave Neumann
    [email protected]

    You can also use the "Scan from String" function. If the "remaining string" output is not a null string, or the error output is reporting an error, something went wrong with the conversion.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Searching a list of character in a String

    I am new to java and i have i simple question for you:
    i know with string.indexOf("char", start, end); i can search for a specific string.
    But how can i search for a list of Strings?
    Thanks in advance.

    I am new to java and i have i simple question for
    you:
    i know with string.indexOf("char", start, end); i can
    search for a specific string.
    But how can i search for a list of Strings?
    Thanks in advance.I am not quite sure what you mean by 'list of strings', but from your example I assume you mean a set of characters for which you can do something like the following:
    if ("aeiou".indexOf(c) >= 0) isVowel = true;
    and for list of strings use same method indexOf(String) or indexOf(Strinf, index)
    and to test 'list of strings' or multiple from previous ex...use an array of String[]
    hope this relevant and clear enough

  • Oracle function to caclulate occurance of a character in a string

    Hi All,
    I have a string lets say :
    'rahul|rahul|rahul|'
    I want to calculate the occurance of the charachter '|' which is 3.
    PS : I dont want to use connect by or reg_exp and I am using oracle 9i
    Regards
    Rahul

    Hi,
    Mac_Freak_Rahul wrote:
    looking for an oracle built-in function.Sorry, there are only a couple of hundred built-in functions. To do any of the millions of things people want, they sometimes have to combine two or more of those functions, as Paul did.
    Acutally, there is a single built-in function that does this, REGEXP_COUNT, but it was only introduced in Oracle 11.1, so it doesn't help you. The fact that they made a new function in Oracle 11 hints that the way to get the same results in earlier versions was too complicated, so don't be surprised if the best way to do this in Oracle 9 isn't as easy you'd like.
    What exactly don't you like about Paul's solution?
    Paul's solution is what I would use. If you have a reason why you can't use it, say what that reason is, and someone will help you work around it. I can think of other ways to get the same results, including returning 0 when the string doesn't contain any of the designated character, but posting them will only waste your time (not to mention mine) if they have the same problem that Paul's solution has, whatever that is.

  • How to remove /delete a particular character in a String

    Hii
    i have this problem.In order to specify the number of decimal palces for a double type variable,i have used the
    NumberFormat class.
    My code ;
    Double x=234566.4 ;
    NumberFormat n1= NumberFormat.getInstance();
    n1.setMaximumFractionDigits(2);
    n1.setMinimumFractionDigits(2);
    String st=n1.format(x);
    out.print(st) ;
    is giving me 2,34,566.40 which I dont want I want to have it lik 234566.40
    since i will again put it in function Integer.parseInt/Double.parseDouble...so those commas are giving me errors.So can anybody suggest how to remove those commas from that string...It would be of gr8 help.thanx
    Arnab

    hi
    You can use StringTokenizer
    Your code
    Double x=234566.4 ;
    NumberFormat n1= NumberFormat.getInstance();
    n1.setMaximumFractionDigits(2);
    n1.setMinimumFractionDigits(2);
    String st=n1.format(x);
    out.print(st) ;
    StringTokenizer sT = new StringTokenizer(st,",");
    String newstring="";
    while(sT.hasMoreTokens())
    newstring += sT.nextToken();
    out.println(newstring);
    this may help out
    cheers
    rambee

  • Searching for percent character (%) in a string

    Hi All,
    A strange request from one of our developers that I have not come across before.
    Is there a way to search for a percent character (%) in a string and also use the wildcard special character (%)?
    i.e. to return all values with a percent character (%)
    e.g. select column1 from table1 where column1 like '%%';
    When I do this all records are returned.
    Regards!!

    or use an INSTR function.If INSTR comes, can REGEXP be far behind ? - Ode to the Warren Tolentino... ;)
    test@ORA10G>
    test@ORA10G> @ver1
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    test@ORA10G>
    test@ORA10G> with t as
      2   (select 'the percentage (%) determines the final results' remarks from dual union all
      3    select 'otherwise non at all' remarks from dual)
      4  select * from t
      5  where regexp_like (remarks,'%');
    REMARKS
    the percentage (%) determines the final results
    test@ORA10G>
    test@ORA10G> with t as
      2   (select 'the percentage (%) determines the final results' remarks from dual union all
      3    select 'otherwise non at all' remarks from dual)
      4  select * from t
      5  where regexp_instr (remarks,'%') > 0;
    REMARKS
    the percentage (%) determines the final results
    test@ORA10G>
    test@ORA10G>pratz

  • How to delete last character in a string

    Guys i have a question...
    how can i delete the last character in a string..
    for example
    String myString = "helloWorld, ";
    how do i delete the last character in this string which is a "," ?

    String newString = myString.substring(0, myString.length()-1);

Maybe you are looking for