Get the number of occurences in a text

Hi,
Is there any way by which i can check the number of occurences of a word in a text ???
for eg. i an have 'i am a good boy and i am a good man'
i wnt to check the number of occurences of good in the above statemnt
Ny way to do that..........
Thanks

Well, it was a silly suggestion from me regarding ";" or "." - of course they are nonword characters.
Basically, the issue is the same as with
SQL> with t as (
  2    select ' good good good good good good ' s from dual
  3  )
  4  select
  5  s,
  6  regexp_count(s,' good ') reg_count
  7  from t
  8  ;
S                                REG_COUNT
good good good good good good           3And i don't see at the moment a simple workaround...
Best regards
Maxim

Similar Messages

  • How to get the number of lines of a file?

    Folks:
    Is there a way to get the number of lines of a text file? I don't know if there is an existing method to do that.
    Thanks a lot.

    HI
    I found some solution
    other than increment loop and all
    here is the code it might helpful to u
    //returns the number of lines in a file
    //author : Ravindra S
    //Symphony software Hyderabad
    try
    RandomAccessFile randFile = new RandomAccessFile(csvFile,"r");
    long lastRec=randFile.length();
    randFile.close();
    FileReader fileRead = new FileReader(csvFile);
    LineNumberReader lineRead = new LineNumberReader(fileRead);
    lineRead.skip(lastRec);
    countRec=lineRead.getLineNumber()-1;
    fileRead.close();
    lineRead.close();
    catch(IOException e)

  • How to get the number of routes in MLS L3SW table with SNMP

    Hello experts,
    Is there any way to get the number of routes in the MLS-hardware Layer 3-switching table with SNMP, like with CLI command "show mls cef summary"?
    If possible, please let me know the OID and which MIB do I use.
    [e.g.]
    #show mls cef summary
    Total routes: 400000
    <omit>
    ====
    Device : C6509E
    IOS : s72033-advipservicesk9_wan-mz.122-33.SXH3a.bin
    ====
    Thank you,

    function buttonClick()
    var table = profileTable;
    var lnRow = table.rows.length;
    var insertedRow = table.insertRow(parseFloat(lnRow));
    var cell1 = insertedRow.insertCell();
    cell1.innerHTML ="<tr><td><Input type=\"hidden\" >>>name=\"rowNum\" value="+cnt"+></td></tr>";
    document.profileform.submit;
    on submit it goes to the second page, but the value i got using >>>System.out.println("row number from text >>>box"+request.getParameter("rowNum")); is null. What is wrong with >>>my coding. Can anyone solve this.HI carry
    Check the value of bold data
    function buttonClick()
    var table = profileTable;
    var lnRow = table.rows.length;
    var insertedRow = table.insertRow(parseFloat(lnRow));var cnt=inRow
    var cell1 = insertedRow.insertCell();
    cell1.innerHTML ="<tr><td><Input type=\"hidden\" >>>name=\"rowNum\" value="+cnt+"></td></tr>";
    document.profileform.submit;
    }try with it

  • How to get the number of messages consumed by a MDB ??

    Hi all,
    How to get the number of messages consumed by a MDB displayed in OEM in a Java Application ???
    DMS ??? what use DMS ???
    tanks

    ok.
    Well using DMS is one way to get at these sorts of stats in a programmatic manner.
    There's a Java API you can use, or you could call out to the Spy servlet to query the DMS stats in either text or XML form.
    I don't have an MDB published so I can't show you specifiically, but here's the sort of query you can use to extract the data.
    http://localhost:8888/dms0/Spy?format=raw&table=oc4j_ejb_stateless_bean&recurse=children
    Which produces a table of the TEXT form:
    <DMSDUMP version='9.0.4' timestamp='1163456821185 (Tue Nov 14 08:57:01 CST 2006)' id='8888' name='OC4J'>
    <statistics>
    /oc4j [type=n/a]
    /oc4j/default [type=oc4j_ear]
    /oc4j/default/EJBs [type=oc4j_ejb]
    /oc4j/default/EJBs/jmsrouter_ejb [type=oc4j_ejb_pkg]
    /oc4j/default/EJBs/jmsrouter_ejb/AdminMgrBean [type=oc4j_ejb_stateless_bean]
    pooled.count:     11     ops
    pooled.maxValue:     1     count
    pooled.minValue:     0     count
    pooled.value:     0     count
    ready.count:     11     ops
    ready.maxValue:     1     count
    ready.minValue:     0     count
    ready.value:     0     count
    session-type.value:     Stateless     
    transaction-type.value:     Bean     
    /oc4j/default/EJBs/jmsrouter_ejb/EnqueuerBean [type=oc4j_ejb_stateless_bean]
    pooled.count:     11     ops
    pooled.maxValue:     0     count
    pooled.minValue:     0     count
    pooled.value:     0     count
    ready.count:     11     ops
    ready.maxValue:     0     count
    ready.minValue:     0     count
    ready.value:     0     count
    session-type.value:     Stateless     
    transaction-type.value:     Bean     
    /oc4j/default/EJBs/jmsrouter_ejb/TimerHandlerBean [type=oc4j_ejb_stateless_bean]
    pooled.count:     11     ops
    pooled.maxValue:     0     count
    pooled.minValue:     0     count
    pooled.value:     0     count
    ready.count:     11     ops
    ready.maxValue:     0     count
    ready.minValue:     0     count
    ready.value:     0     count
    session-type.value:     Stateless     
    transaction-type.value:     Bean     
    </statistics>
    </DMSDUMP>
    Or produces an XML document of the form:
    http://localhost:8888/dms0/Spy?format=xml&table=oc4j_ejb_stateless_bean&recurse=children
    You can use the Spy console to find the table that contains the details for MDB and then take it from there.
    This is not what you specifically want to do, but it does provide a good overview of how DMS is used.
    http://www.oracle.com/technology/pub/notes/technote_dms.html
    -steve-

  • How do i change the number of columns within a text box?  I need to go from three columns to one.

    How do I change the number of columns within a text box?  I need to go from 3 columns to 1.  The insert column is highlighted and column break does not work for this.

    Pages '09 does not seem to allow layout breaks in Textboxes.
    Pages 5.2 has the same limitation.
    Use multiple linked Textboxes in Pages '09 to get the layout you want or create your layout in a Word Processing template in the document layer.
    Peter

  • Count the number of occurence in table with toplink

    Hi !
    there is no way to build a query with expressionbuilder or .... to count the number of occurences in my table ?
    i don't want use query " select count(*) from table "
    thanks

    Not sure of the question. Are you looking to get the sql "select count(*) from table" from using the TopLink expression framework or are you getting that SQL already and want something else?
    If you are looking just to get the count from a table/class, you can use a ReportQuery:
    ReportQuery rquery = new ReportQuery(ClassToQueryOn.class);
    rquery.addCount(); //equivalent to count(*);
    session.executeQuery(rquery);
    You can use a report query to return data instead of objects, and use selection criteria just like a normal read query.
    Best Regards,
    Chris

  • Count the number of occurences of a pattern in some files

    Hi,
    I am trying to extract some patterns in files using regex. I can easily extract the patterns using my program. I also wanted to count the number of occurences of the pattern in the files. For that I have written this code:
    int count=0;
              while (m.find())
                 System.out.println("Found Patterns: "+m.group());
                 count++;
           System.out.println(count);  //giving error saying identifier expectedUnfortunately I am getting an error saying identifier expected at the count line. What to do?
    Thanks

    Cheapside-Poultry wrote:
    Move the } down one line so the count is in scope.No, it looks like he just forgot the opening { with the while.                                                                                                                                                                                                                                                                                                                                       

  • Mapping Query : Can I get the Number Occurance of a segment

    Can I get the Number Occurance of a segment
    Source MSG
    Tree             Occurence
    **File_Message    (1..1)
    .....Name         (1..1)
    .....Sal          (1..1)
    .....**Details    (1..Unbound)   
    .........MailID   (1..1) 
    .........MobileNO (1..1)     
    Target MSG
    **CountDetails   (1..1)
    .....Count       (1..1)
    In Target MSG, I want the number of occurance of the FileDeatils-->Details 
    if source file is like follow
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:File_Message xmlns:ns0="urn:test:ns:ns">
       <Nam>John</Nam>
       <Sal>2342</Sal>
       <Details>
          <MailID>[email protected]</MailID>
          <TelNo>345345345</TelNo>
       </Details>
       <Details>
          <MailID>[email protected]</MailID>
          <TelNo>888888888</TelNo>
       </Details>
    </ns0:File_Message>
    I need to get the taget Message as follow
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:CountDetails xmlns:ns0="urn:test:ns:ns">
       <Count>2</Count>
    </ns0:CountDetails>
    in Count Tag I should get the number of occurance of Details Tag in source MSG
    Can any one help regard this
    Thanks is advance

    Hai Mohan,
       My Real Problem is
    I am Using the Scenario File--> XI --IDoc (Using BPM)
    File is having the following value
    Header Details (one Occurance)
    PO(1..Unbound)
    for Example that file having 2 PO (Purchase Order) Then I have to split that file in to two files..
    and I have to pass that two files to Post Idoc(0rders02) for create sal Order.
    That file may have more than one PO
    Please give Ur Suggest me on this
    Thanks in advance
    Dhanabal T

  • Problems with getting the number of hits in the document.

    I need to get the number of hits in the document.
    I use the query template for this porpose as:
    SELECT d.id, score(1)
    FROM document d
    WHERE contains(d.content,'<query>
    <textquery>SEARCHWORD</textquery>
    <score datatype="INTEGER" algorithm="COUNT"/></query>',1)>0
    AND d.id=1
    problems:
    1. If I have some synonyms associated with SEARCHWORD in OracleThesaurus and in case if document contains these synonyms they are not counted.
    2. could you explain the following results returned by query above:
    search query: word1 - numberOfHits=10
    search query: word2 - numberOfHits=8
    search query: word1 OR word2 - numberOfHits=10
    i suppose that numberOhHits=18 for a query: word1 OR word2

    Hi.<br><br>
    1.Synonyms (and generally thesaurus query extensions) cannot automatically uses in queries. You MUST expand you query using SYN function yourself. Query you write just applicable for only KEYWORD search.<br><br>
    2. Ask yourself. I'm not seen your data. ;)<br>
    Rgrds, Yuri.<br><br>
    PS. Just read Oracle Text Reference - you can find many answers here. ;)

  • I need to WAP to count the number of occurences of an alphabet in a string.

    I need to WAP to count the number of occurences of an alphabet in a string.I tried a lot and have surfed a lot regarding this problem.
    I m not the most proficient with java.but this is all i could come up with,and would appreciate some help here.I hope you guys would help me find a solution to this.
    e.g String : abcabrty
    Result should be
    a:2
    b:2
    c:1
    r:1
    t:1
    y:1
    public class chkoccurences
         public static void main(String args[ ])
              String user_Data=args[0];
              int counter=0;     
              try
                   for(int i=0;i<user_Data.length( );i++)
                        for(int j=0;j<user_Data.length( );j++)
                             if(user_Data.charAt(i) == user_Data.charAt(j))
                             counter++;
                        System.out.println(user_Data.charAt(i)+" exists "+counter+" time(s) in the word.");
                   System.out.println(" ");
              catch(ArrayIndexOutOfBoundsException e)
                   System.out.println("Check the array size.");
    }This is the output i get out of the program:
    a exists 2 time(s) in the word.
    b exists 4 time(s) in the word.
    c exists 5 time(s) in the word.
    a exists 7 time(s) in the word.
    b exists 9 time(s) in the word.
    r exists 10 time(s) in the word.
    t exists 11 time(s) in the word.
    y exists 12 time(s) in the word.What i think is i need an array to store the repeated characters because the repeated characters are getting counted again in the loop,if you know what i mean.
    Please, i would appreciate some help here.

    Criticism is welcomed
    public class tests {
         final int min = 10;
         final int max = 35;
         final char[] chars = new char[] {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
                   'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
                   'v', 'w', 'x', 'y', 'z'};
         public static void main(String[] args){
              tests t = new tests();
              String[] strings = new String[] {"aabcze", "att3%a", ""};
              for(String s : strings){
                   System.out.println(t.getAlphaCount(s));
         public String getAlphaCount(String s){
              int[] alphaCount = new int[26];
              int val;
              for(char c : s.toCharArray()){
                   val = Character.getNumericValue(c);
                   if( (val>=min) && (val<=max)){
                        alphaCount[val-min]++;
              StringBuilder result = new StringBuilder();
              for(int i=0; i<alphaCount.length; i++){
                   if(alphaCount[i] > 0){
                        result.append(chars[i] + ":" + alphaCount[i] + ", ");
              if(result.length() != 0){
                   result.delete(result.length()-2, result.length());
              return result.toString();
    }

  • Fastest way to count the number of occurences of string in file

    I have an application that will process a number of records in a plain text file, and the processing takes a long time. Therefore, I'd like to first calculate the number of records in the file so that I can display a progress dialog to the user (e.g. " 1234 out of 5678 records processed"). The records are separated by the string "//" followed by a newline, so all I need to do to get the number of records is to count the number of times that '//' occurs in the file. What's the quickest way to do this? On a test file of ~1.5 Gb with ~500 000 records, grep manages under 5 seconds, whereas a naive Java approach:
    BufferedReader bout = new BufferedReader (new FileReader (sourcefile));
                   String ffline = null;
                   int lcnt = 0;
                   int searchCount = 0;
                   while ((ffline = bout.readLine()) != null) {
                        lcnt++;
                        for(int searchIndex=0;searchIndex<ffline.length();) {
                             int index=ffline.indexOf(searchFor,searchIndex);
                             if(index!=-1) {
                                  //System.out.println("Line number " + lcnt);
                                  searchCount++;
                                  searchIndex+=index+searchLength;
                             } else {
                                  break;
                   }takes about 10 times as long:
    martin@martin-laptop:~$ time grep -c '//' Desktop/moresequences.gb
    544064
    real     0m4.449s
    user     0m3.880s
    sys     0m0.544s
    martin@martin-laptop:~$ time java WordCounter Desktop/moresequences.gb
    SearchCount = 544064
    real     0m42.719s
    user     0m40.843s
    sys     0m1.232sI suspect that dealing with the file as a whole, rather than line-by-line, might be quicker, based on previous experience with Perl.

    Reading lines is very slow. If your file has single byte character encoding then use something like the KMP algorithm on an BufferedInputStream to find the byte sequence of "//\n".getBytes(). If the file has a multi-byte encoding then use the KMP algorithm on a BufferedReader to find the chars "//\n".getCharacters() .
    The basis for this can be found in reply #12 of http://forum.java.sun.com/thread.jspa?threadID=769325&messageID=4386201 .
    Edited by: sabre150 on May 2, 2008 2:10 PM

  • How to count the number of occurences of a character

    hi
    wat command is used to count the number of occurences of a charcter in a line?
    i have to count the number of '.' in a line

    FIND
    Searches for patterns.
    Syntax
    FIND <p> IN [SECTION OFFSET <off> LENGTH <len> OF] <text>
                [IGNORING CASE|RESPECTING CASE]
                [IN BYTE MODE|IN CHARACTER MODE]
                [MATCH OFFSET <o>] [MATCH LENGTH <l>].
    The system searches the field <text> for the pattern <p>. The SECTION OFFSET <off> LENGTH <len> OF addition tells the system to search only from the <off> position in the length <len>. IGNORING CASE or RESPECTING CASE (default) specifies whether the search is to be case-sensitive. In Unicode programs, you must specify whether the statement is a character or byte operation, using the IN BYTE MODE or IN CHARACTER MODE (default) additions. The MATCH OFFSET and MATCH LENGTH additions set the offset of the first occurrence and length of the search string in the fields <p> and <l>.

  • User-Exit after saving VA01 to get the number of Sales Order.

    Hi everyone,
    I hope you all fine!
    I really need your help to get a user-exit or BADI for the VA01 transaction,  because after pushing the save button I need to get the number of sales order, so I can create a header text, but to use a Function Module to do that, I need the sales order first.
    I hope You can help me with this.
    Thanks for your time.
    Regards,

    Hi,
          Goto se38 ,
        1. Enter prog. name  "MV45AFZZ"
        2. Choose "Enhance"  from application tool bar,
        3. Edit>Enhanc.Operations>Show implicit Enhance...
        4.Right click>Enhancement Impliment> Create....,Before that,you have to choose which subroutine is suitable for your scenario...then you can code it .
       Also,try this user exit -->"V45E0001"
    I hope ,it will help you...
    <<=< Sharing Knowlede is a way to Innovative >>=>
    By,
      Yoga

  • Get the number of concurrent users for a WD application

    Hi all,
    I need to implement a method which counts the number of concurrent users for a Web Dynpro application.
    Say I have a portal with X applications, is there API that can tell me how many users are working on specific application?
    I know that this line of code
    IWDClientUser currentUsers[] = WDClientUser.getClientUsers();
    will get me the number of users that are working on ALL Web Dynpro applications. Is there a way of getting it for specific application?
    I thought of using a text file/small DB table that set/get the number of users but I think it will cause overhead issues.
    Any ideas how to implement it?
    Thanks,
    Omri

    Hi Omri,
    Try using  WDServerState.getActualApplications() method.It returns array of actual running applications.Compare ur application name with the array elements and keep a counter for matching elements.
    String app[]=WDServerState.getActualApplications();
        for(int i=0;i<app.length;i++)
              view.getComponent().getMessageManager().reportSuccess(
               app<i>);

  • How to find the number of occurence of a string

    String str="The AR tech seeks experienced candidates in java,jsp. The candidates should have atleast 1 year of experience in the specified skills.";
    here i need to find the number of occurence of the string "experience".
    how to find it out?

    String str="The AR tech seeks experienced candidates in java,jsp. The candidates should have atleast 1 year of experience in the specified skills.";
    String findStr = "experience";
    int count = 0;
    int index = 0;
    while(index != -1) {
    index = str.indexOf(findStr, (count == 0 ? 0 : index + findStr.length()));
    if(index != -1) {
    count++;

Maybe you are looking for

  • Error While Running the Interest Calculation in tcode FINT

    Dear All, I have configured Item Interest Calculaiton for SPL GL Transactions for Customers like "Advances to Customer" , Here once certain period is exceeded for receiving goods from customers interest to be received from customers .. pls notice tha

  • DTP Filter Variable

    Hi All, We would like regionalize the data loads based on Region. Extracting data from CRM Source. We have maintained Region Values in (Variable table) SM30, created three Variables for three regions and maintained Region values correspondingly.    (

  • Disable Elements 8 Organizer due to using Lightroom and want to still use PSE

    I have installed and now use Lightroom. I still want to use Elements 8 Editor to further edit images. Every image I edit ends up in the Elements Organizer. I need help preventing my newly edited images from finding their way into Elements Organizer.

  • How to Add a graphical Sequence panel  in a webhelp layout?

    Hi, Can anyone please let me know how to add a graphical pane on the top right of every topic which would show the flow of sequence, the single source layout being webhelp. I'll be more clear...... If we click on Help>Tutorial>HTML ROBOHELP Tutorial.

  • Download HD episode only?

    Hi I'm new to iTunes store and I like it very much. One thing bothering me is that whenever I purchase an HD episode, iTunes download both the HD and SD versions. If I stop and delete the SD download, iTunes just start it again next time I launch it.