Count of words in a string

i have a string "hai oracle tech team"
i want to calculate the number of words in it
i.e. it should return 4
how to do it

Haven't you answers in your duplicate thread from the last week ?
Re: how to calculate the number of words in a column
Nicolas.

Similar Messages

  • How i can count the number of words in a string?

    hi, i want to know how to count the number of words in a string
    e.g. java is a very powerful computer language.
    i will get 7 words.
    thanks in advance..

    Jverd, this has actually been answered, but due to an
    attack of goldie-itis, all the answers were hosed.
    The OP did get an answer, though.Yeah, I know. I just didn't know if he saw the answer before it went away.

  • Counting a particular word in a string

    Hi All,
    Have a query to find the occurence of a particular word in a string using a query.
    ex: str := 'a,b,a,c,d'
    search_str := 'a'
    => need to get the number of times 'a' is getting repeated in the string str.
    output: 2
    Hoping for the best support as always.
    Edited by: Aparna16 on Jul 17, 2012 5:55 AM
    Edited by: Aparna16 on Jul 17, 2012 5:56 AM

    SQL> ed
    Wrote file afiedt.buf
      1  with sample_data as
      2  (
      3  select 'aaa,abcdd,abc,abc,asdasd' cola, 'abc' matchCol from dual union all
      4  select 'a,b,a,c,d', 'a' from dual union all
      5  select 'a,b,a,c,d', 'e' from dual  union all
      6  select  'aaa,abcdd,abc,abc,asdasd,abc', 'ab' from dual union all
      7  select  'aaa,abcdd,abc,abc,asdasd,abc', 'abc' from dual
      8  )
      9  select cola, matchcol, length(cola||',') - length(replace(cola||',',matchcol||',',substr(matchcol,2)||','))  cnt
    10* from sample_data
    SQL> /
    COLA                         MAT        CNT
    aaa,abcdd,abc,abc,asdasd     abc          2
    a,b,a,c,d                    a            2
    a,b,a,c,d                    e            0
    aaa,abcdd,abc,abc,asdasd,abc ab           0
    aaa,abcdd,abc,abc,asdasd,abc abc          3

  • Find word in text file and count specific words

    now I'll try to explain what I need to do. I have file.txt file, It looks like:
    John //first line - name
    One
    Three
    Four
    Peter //first line - name
    Two
    Three
    Elisa //first line - name
    One
    Three
    Albert //first line - name
    One
    Three
    Four
    Nicole //first line - name
    Two
    FourSo I have program's code:
    public class Testing {
            public static void main(String args[]) throws Exception {
                Scanner input = new Scanner(System.in);
                System.out.println("Select word from list:");
                System.out.println();
                try {
                    FileReader fr = new FileReader("src/lt/kvk/i3_2/test/List.txt"); // this is list of words, everything all right here
                    BufferedReader br = new BufferedReader(fr);
                    String s;
                    while((s = br.readLine()) != null) {
                        System.out.println(s);
                    fr.close();
                    String stilius = input.nextLine();   // eneter word which I want to count in File.txt
                    BufferedReader bf = new BufferedReader(new FileReader("src/lt/kvk/i3_2/test/File.txt")); // from this file I need to count word which I entered before
                    int counter = 0;               
                    String line;
                    System.out.println("Looking for information");
                    while (( line = bf.readLine()) != null){
                        int indexfound = line.indexOf(stilius);
                        if (indexfound > -1) {
                             counter++;
                    if (counter > 0) {
                        System.out.println("Word are repeated "+ counter + "times");}
                        else {
                        System.out.println("Error...");
                    bf.close();
                catch (IOException e) {
                    System.out.println("Error:" + e.toString());
            }This program counting specific word (entered by keyboard) in file.txt.
    I need to make this program: for ex.: if I enter word: One It must show:
    Word One repeated 3 times by John, Elisa, AlbertAll what I need to elect by who this word repeated. But I don't know really how to make It, maybe LinkedList or I dont know, someone could help me?
    Thank you very much.

    966676 wrote:
    All what I need to elect by who this word repeated. But I don't know really how to make It, maybe LinkedListYou should choose the simplest type fullfilling your needs. In this case I'd go for <tt>HashSet</tt> or <tt>ArrayList</tt>.
    or I dont know, someone could help me?You need to introduce a variable to store the actual name which must be resetted if an empty line is found and then gets assigned the verry next word in the file.
    bye
    TPD

  • How to count a occurence of a string in file

    import java.util.*;
    import java.io.*;
    class Count
    public static void main(String args[ ] )throws Exception
         FileReader fr=new FileReader("d:\\compfetch\\clean\\first.txt");
         BufferedReader br=new BufferedReader(fr);
         StringBuffer sb=new StringBuffer();
         while((s=br.readLine())!=null)
              sb.append(s);
         s=sb.toString();
    Vector v= new Vector();
         v.addElement("job");
         v.addElement("jobs");
         v.addElement("career");
         v.addElement("careers");
         v.addElement("vacancy");
         v.addElement("vacancies");
         v.addElement("opportunity");
         v.addElement("openings");
         v.addElement("posting");
         v.addElement("postings");
         v.addElement("opportunities");
         v.addElement("placement");
         v.addElement("placements");
         v.addElement("job");
         v.addElement("job");
         Enumeration vEnum=v.elements();
         while(vEnum.hasMoreElements())
              System.out.println(vEnum.nextElement());
    I need to count the occurence of each string given in the vector from the text file.I have the file and the vector.How do i compare the vector and textfile ,so that i can count the occurence of eachString in the vector with the text file.The text file may contain any of the words given in the vector.If found ,a count shld be made for each string .
    regards,
    koel

    Try this code:
    import java.util.*;
    import java.io.*;
    class Count
    public static void main(String args[ ] )throws Exception
         FileReader     fr = new FileReader("c.c");
         BufferedReader br = new BufferedReader(fr);
         StringBuffer   sb = new StringBuffer();
         String         s;
         while((s=br.readLine())!=null)
              sb.append(s);
         s=sb.toString();
         Vector v= new Vector();
         v.addElement("job");
         v.addElement("jobs");
         v.addElement("career");
         v.addElement("careers");
         v.addElement("vacancy");
         v.addElement("vacancies");
         v.addElement("opportunity");
         v.addElement("openings");
         v.addElement("posting");
         v.addElement("postings");
         v.addElement("opportunities");
         v.addElement("placement");
         v.addElement("placements");
         Enumeration vEnum=v.elements();
         while(vEnum.hasMoreElements())
              String l = (String)vEnum.nextElement();
              int    a = 0;
              int    p = s.indexOf(l,a);
              int    c = 0;
              while (p != -1)
                   c = c + 1;
                   a = a + l.length() + p;
                   p = s.indexOf(l,a);
              System.out.println(l+"  "+c);
    }

  • Hou can I count the words on a text

    I am using Iterator which I think it only counts unique word so who can I count the all the words on the text

    See i have Thispublic int getCount(String word) {
              // returns count for word
              Iterator<StringCounter> iter = ourWords.iterator();
              StringCounter sc;
              int count=0;
              while (iter.hasNext()) {
                   sc = iter.next();
                   if (sc.getString().equals(word)) {
                        sc.increment();
                   count++;
              return count;
         }this only gets the words that are unique

  • How can i count the word in a cell.

    Dear Experts,
    i want to count the word in cell how can i do this ?
    Isthere any function ?
    plz give logic or command.

    You can ty :
    SQL> var text varchar2(50)
    SQL> exec :text := 'How do I count the number of words in my cell?'
    PL/SQL procedure successfully completed.
    SQL> select text,
      2         sum(case when substr(text,rownum,1)=' '
      3                       and substr(text,rownum-1,1)!=' '
      4                  then 1
      5                  else 0 end) nb_word
      6  from (select rownum,:text||' ' text,length(:text) ln from dual)
      7  connect by level <= ln+1
      8  group by text
      9  /
    TEXT
       NB_WORD
    How do I count the number of words in my cell?
            11
    SQL>  exec :text := 'How     do I count the number of words in my   cell?    '
    BEGIN :text := 'How     do I count the number of words in my   cell?    '; END;
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at line 1
    SQL> var text varchar2(1000)
    SQL> exec :text := 'How     do I count the number of words in my   cell?    '
    PL/SQL procedure successfully completed.
    SQL> select text,
      2         sum(case when substr(text,rownum,1)=' '
      3                       and substr(text,rownum-1,1)!=' '
      4                  then 1
      5                  else 0 end) nb_word
      6  from (select rownum,:text||' ' text,length(:text) ln from dual)
      7  connect by level <= ln+1
      8  group by text
      9  /
    TEXT
       NB_WORD
    How     do I count the number of words in my   cell?
            11
    SQL> select * from v$version where rownum=1;
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.7.0 - Production
    SQL> Nicolas.
    Well, we can discuss about what limit a word : here space, but there is point, double-point, and so on... And about what is a word : do the punctuation is a word ?
    For example :
    "It's a word !"=>how many words are in this sentence ?
    http://en.wikipedia.org/wiki/Word
    Message was edited by:
    N. Gasparotto

  • Here's how to find the right word in a string

    I needed to find the rightmost word in a string. I didn't find a simple formula in these forums, but I now have one, so I wanted to share it. Hope you find it useful.
    Assuming that the string is in cell A1, the following will return the rightmost word in the string:
    RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1," ","*",LEN(A1)-LEN(SUBSTITUTE(A1," ","")))))

    I found the problem. Whatever character was being used in the substitution was parsed out by the forum parser. I replaced it with "œ" (option q on my keyboard).
    =RIGHT(A1,LEN(A1)-FIND("œ",SUBSTITUTE(A1," ","œ",LEN(A1)-LEN(SUBSTITUTE(A1," ","")))))
    Still needs an error check for a single-word "sentence" and to remove the trailing period but it does seem to work. Pretty slick.
    Message was edited by: Badunit
    I see below that the problem was fixed by the OP.
    Message was edited by: Badunit

  • How to read each and every word from a string.

    Hi all,
       I have a string which is having many label numbers. if the string is lv_str, its value is like, 11111111111111##22222222222222##3333333333333.
    I need to move the values alone into internal table. each value should be updated as a single row into one internal table. How to read each and every word of the string and move to an internal table.
    the internal table should be like this.
    11111111111111
    22222222222222
    3333333333333
    Can any one give me a suggestion in this regard.
    POINTS PROMISED.
    Regards,
    Buvana

    Hi,
    If you know the format and length of the data
    Use split at '#' so that you will get the individual values.
    Thean append it to internal table.
    Reward iof helpful.

  • 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 get the second and third.... words in a string

    Hi all,
    is there any way to get the words in a string seperate columns in a row.
    "xxx yyyy zzzz aaaa bbbb"
    required answer is
    a b c d e
    xxx yyyy zzzz aaaa bbbb
    a b c d e are the column names
    Thanks

    WITH t as (
      SELECT 'xxx yyyy zzzz aaaa bbbb' as t FROM dual
    -- end of sample data.
    SELECT t,
           regexp_substr(t, '[^ ]+', 1, 1) as a,
           regexp_substr(t, '[^ ]+', 1, 2) as b,
           regexp_substr(t, '[^ ]+', 1, 3) as c,
           regexp_substr(t, '[^ ]+', 1, 4) as d,
           regexp_substr(t, '[^ ]+', 1, 5) as e
      FROM t;
    T                       A                       B                       C                       D                       E                    
    xxx yyyy zzzz aaaa bbbb xxx                     yyyy                    zzzz                    aaaa                    bbbb                   

  • Replacing first Character of every word in a string with an Uppercase

    Hi,
    Is it possible to replace all first character of every word in a string with UpperCase?
    $="autocad lite"
    Should look "Autocad Lite" .
    Thanks,
    François

    Hi FRacine,
    Please refer to the script below:
    $givenname="autocad lite"
    $givenname
    $givenname = $givenname.substring(0,1).toupper()+$givenname.substring(1)
    $givenname
    Edit: to change first character in every word, please refer to this script, this may not be the best way, but it can work:
    $givenname="autocad lite"
    $givenname
    $words=$givenname.split(" ")
    $givenname=""
    foreach ($word in $words){
    $givenname+=$word.substring(0,1).toupper()+$word.substring(1)+" "}
    $givenname=$givenname.trim()
    $givenname
    If there is anything else regarding this issue, please feel free to post back.
    Best Regards,
    Anna Wang

  • To get Length of each word in a String.

    Hi,
    I wanted to know, how to calculate the length of each word in a string.Suppose for example if the input is like this:
    i/p:'Tech on the Net'
    o/p:4 2 3 3
    ie Tech-4 on-2 the-3 Net-3
    another Ex:i am a good boy
    o/p:1 2 1 4 3
    Kindly let me know any PL/SQL function or SQL query which would help to achieve this.
    Thanks&Regards
    Zaheer

    sql>select substr('tech on the net',decode(n,0,1,instr('tech on the net',' ',1,n)+1),
                  decode(instr('tech on the net',' ',1,n+1),0,length('tech on the net')-instr('tech on the net',' ',1,n),
                        instr('tech on the net',' ',1,n+1)- decode(n,0,0,instr('tech on the net',' ',1,n))-1)) wrd,
          length(substr('tech on the net',decode(n,0,1,instr('tech on the net',' ',1,n)+1),
                  decode(instr('tech on the net',' ',1,n+1),0,length('tech on the net')-instr('tech on the net',' ',1,n),
                        instr('tech on the net',' ',1,n+1)- decode(n,0,0,instr('tech on the net',' ',1,n))-1))) cnt
    from(select rownum-1 n
         from dual
         connect by level <= length('tech on the net') - length(replace('tech on the net',' ',''))+1)
    WRD CNT
    tech  4 
    on  2 
    the  3 
    net  3                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Delete the first word in a string?

    Hi, i have a code in which i can extract the first three words in a string. after it's found the three first words, i would like it to remove the first one, what could i add?
    this is what the code looks like:
    import java.util.regex.*;
    class Test187D {
         public static void main(String[] args) {
              String word1;
              String word2;
              String word3;
              String partDesc = "Hi my name is SandraPandra";
              Pattern pattern = Pattern.compile("^(\\w+)\\s+(\\w+)\\s+(\\w+)");
              Matcher matcher = pattern.matcher(partDesc);
              //Find the first word of the part desc
              if (matcher.find()) {
                   word1 = matcher.group(1);
                   word2 = matcher.group(2);
                   word3 = matcher.group(3);
                   System.out.println (word1 + " " + word2 + " " + word3);
    } Thank you in advance

    Take the length of the first word, plus one for the length of the space, that's how many characters to remove. Take the substring of the original string from the end of the removed part to the end of the whole string. Look up the String methods length(), and substring().

  • [svn:fx-trunk] 13501: Bug: BLZ447 - AMF3 Deserialization: Wrongly counted reference ID of duplicated String when in the same message there are Strings with only wildcards

    Revision: 13501
    Revision: 13501
    Author:   [email protected]
    Date:     2010-01-14 06:01:23 -0800 (Thu, 14 Jan 2010)
    Log Message:
    Bug: BLZ447 - AMF3 Deserialization: Wrongly counted reference ID of duplicated String when in the same message there are Strings with only wildcards
    QA: Yes - please keep an eye on AMFX (HTTPChannel) tests.
    Doc: No
    Checkintests: Pass - except the usual 4-5 tests that time out on my machine.
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/rpc/src/mx/messaging/channels/amfx/AMFXDecoder.as

    Dear Pallavi,
    Very useful post!
    I am looking for similar accelerators for
    Software Inventory Accelerator
    Hardware Inventory Accelerator
    Interfaces Inventory
    Customization Assessment Accelerator
    Sizing Tool
    Which helps us to come up with the relevant Bill of Matetials for every area mentioned above, and the ones which I dont know...
    Request help on such accelerators... Any clues?
    Any reply, help is highly appreciated.
    Regards
    Manish Madhav

Maybe you are looking for

  • Restrict manual change in sales order with respect to quotation

    Hi All, The user use to create sales order with respect to quotation.  The user can able to change pricing as well as some header and item fields.  How can I restrict user for manual change in sales order expect some specific fields. Thanks.

  • Trouble connecting Apple TV to Sony TV (KV-24FV10)

    I am having some problems connecting my new Apple TV to my Sony TV (model: KV-24FV10). I used cables that previously was connected to my DVD but when I use them on the ATV the picture is black and white. I plugged the cables in so RED=RED, WHITE=BLUE

  • HT2736 friend in Europe can't download song I gifted.

    how can I send songs from itunes as gifts to friends outside of the US?

  • Accounting for customer inventory in SAP

    Hello Experts Here is a scenario with which i need some help. We sell products to various customers. Consider an example product - say ABC. The product ABC is sold to multiple retail customers. To improve our forecasting and planning accuracy we need

  • Preferences for Item-Level Targeting

    Hey guys, It seems like I have seen some weird issues in the past with multi item-level targeting where a condition happens that causes all items to fail.  I do not use the "Stop processing items in extension on error" option either.  I am trying to