Finding words between keywords in a string

Hi all,
I need to analyze a string like " SELECT this,that,who,what FROM table1". I need all the words between the keywords SELECT and FROM. Unfortunatly the amount of words between select and from can be different, and the words between the select and from need to be placed in a String[] so I can use those to assemble a resultset.
I suspect to make use of java.util.regex.* but exactly how to implement these methods I'm not sure. Could you please advice?
thx!

Hi,
I do not thing this is the wrong forum since it contains very simple algorithem.
Please try the below even I have not tested it.
String sentence = "SELECT this,that,who,what FROM table1";
          String[] strArr = sentence.split(" |,");
          String first = "SELECT";
          String second = "FROM";
          int firstIndex = strArr.length;
          int secondIndex = strArr.length;
          for(int i = 0; i < strArr.length; i++) {
               if(strArr.equals(first)) {
               firstIndex = i+1;
               }else if(strArr[i].equals(second)) {
                    secondIndex = i;
               }else {
                    // nothing;
     if(firstIndex > secondIndex ){
          // error
     System.out.println("words between-->" + (secondIndex -firstIndex));
I hope this could help
Regards,
Alan Mehio
London, UK                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Find space between word with different endings and digit

    Hi,
    I'm trying to figure out how to find spaces between word and digit.
    I am limited to use only word 'WORD' (either capital or small caps) with different endings like -ing -s -y and more (using \S+).
    I wrote something like (?i)(?<=WORD\S+)\s(?=\d+) but this does not seem to work due to some limitation of lookahead I belive?
    Any suggestions?
    Peter

    Peter Stnsz wrote:
    … find what: (\<WORD\S+)(\s)(?=\d)
    change to: $1~s
    Hmmh?
    Your Grep do not find your first example: WORD 0,2 (WORD without any ending)
    And you don't need the second ()
    And please do not use \S
    Use this instead:
    (\<WORD\l*)\s(?=\d)
    (l is the little L)
    Have fun

  • Textedit   select text between keywords

    Hello,
    I have had a search and no luck in finding out how to easily do the below:
    I have been able to successfully copy the contents of a webapge to my textedit.
    What I would now like to do is copy text to clipboard between keywords; for eg.
    File Name image101
    Description
    I would like to copy all the information between "File Name" and "Description"
    Any help is appreciated

    Not sure exactly what you mean by that?
    When I inspect the element all I see is :
    <td width="99%" class="ac td_fname">Changing file name</a></td>
    Im trying to write something that will copy that file name, which changes depending on which webpage you select.

  • Altering the linkage between Keywords and sub keywords

    I have a master folder that contains a series of folders with several thousand images, all with keywords. Things seem to work when I try a FIND, etc. However my old keyword structure needs to be fine tuned. I created a new structure and some of the old image keywords stored in the file metadata do find the corresponding keyword in the new structure. But some images bring in the old structure as a temporary/italicized entry into my new keyword structure. For example, I have an image with the keyword “Calumet”, that’s all I see when I look at the keyword list. My new keyword structure looks like:
    Location (keyword)-Houghton County(sub keyword)-Calumet(sub keyword)
    When I select the image rather than turning on the check in new structure Bridge creates an image of the old structure:
    Locations (keyword)-Hghtn Cnty(sub keyword)-Calumet(sub keyword) in italics.
    Other images with other keywords work but unfortunately there is a series of keywords that continue to bring in the old structure. I can’t visually see how Bridge knows that the image’s use of ‘Calumet’ was originally linked to Hghtn Cnty to Locations when I first added the keywords. I unfortunately assumed that all that was saved was the sub keyword ‘Calumet’ and that Bridge would search my new structure to find a match, “Calumet” to “Calumet”, wherever Calumet appears in the new list. Does anyone know how Bridge saves the links between sub keywords and keywords and how to change that link? I have several thousand images to alter or should I just stick with the old keyword structure?

    Indexing is the key here as you probably have folders that have not been re-indexed under the new scheme.  The search works only on indexed folders, but don't believe it is automatically re-indexed just becasue you made changes.
    My best guess is that you have to dump the cache and let it rebuild, and then re-index your folders.  You could test this by purging the cache for one problem folder (tools/cache/purge cache for xxx folder".  Visit the folder and let it rebuild then do a search on that folder to see it the search now works.
    Rather than dumping the cache you can also try a Find starting at the 1st folder on your drive (it searches from start down directry tree) and check the box for "search non-indexed files" as this re-indexes everything it searches.  That is why it is so slow.
    Hope this solves the problem.

  • Find the nth occurrence of a string in a string

    Hi,
    I'm wondering if there is a method like indexOf, but finds the nth occurrence of a string
    public static int occurrence(java.lang.String str,
                                 java.lang.String toFind,
                                 int occurrence)Cheers
    Jonny

    phdk wrote:
    calypso was refering to promes pseudo code.What is promes? I don't understand the word. Sorry!
    I put the global variable 'count' now in the method occurence
    public static int occurence(String str, String toFind, int occurence){
            int origLength = str.length();
            int count = 0;
            while(str.length()>0){
                str = contains(str, toFind, count);
                   if(count == occurence){
                    int length = str.length();;
                    int actualPos = origLength-(length+1);
                    return actualPos;
                   count++;
            return -1;
    public static String contains(String str, String toFind, int count){
            int occurence = str.indexOf(toFind);
            if(occurence != -1 ){
                 count = count+1;
                return str.substring(occurence+1,str.length());
            }else{
                return "";
      }The output is 1 position to high.
    I still don't get which part of the code to replace with this pseudo code: s'.indexOf('toFind', 'index'+1)
    Sorry for being dimwitted!
    Thanks
    jonny

  • VARCHAR2:: How to differnciate between NULL and empty string '' ?

    Hello to all,
    I'm looking for a possibility to differnciate between NULL and empty string '' in column of type VARCHAR2.
    I have an application relying on that there is a difference between NULL and ''.
    Is it possible to configure ORACLE in some way ?
    Thanx in advance,
    Thomas

    try check if a varchar variable has an empty string
    by checking its lengthAnd that would accomplish what? But see for yourself:
    DECLARE
      v_test VARCHAR2(10);
    BEGIN
      v_test := '';
      DBMS_OUTPUT.put_line(LENGTH(v_test));
      v_test := NULL;
      DBMS_OUTPUT.put_line(LENGTH(v_test));
    END; C.

  • Find and replace value in Delimited String

    Hi All,
    I have a requirement, where i need to find and replace values in delimited string.
    For example, the string is "GL~1001~157747~FEB-13~CREDIT~A~N~USD~NULL~". The 4th column gives month and year. I need to replace it with previous month name. For example: "GL~1001~157747~JAN-13~CREDIT~A~N~USD~NULL~". I need to do same for last 12 months.
    I thought of first devide the values and store it in variable and then after replacing it with required value, join it back.
    I just wanted to know if there is any better way to do it?

    for example (Assumption: the abbreviated month is the first occurance of 3 consecutive alphabetic charachters)
    with testdata as (
    select 'GL~1001~157747~FEB-13~CREDIT~A~N~USD~NULL~' str from dual
    select
    str
    ,regexp_substr(str, '[[:alpha:]]{3}') part
    ,to_date('01'||regexp_substr(str, '[[:alpha:]]{3}')||'2013', 'DDMONYYYY') part_date
    ,replace (str
             ,regexp_substr(str, '[[:alpha:]]{3}')
             ,to_char(add_months(to_date('01'||regexp_substr(str, '[[:alpha:]]{3}')||'2013', 'DDMONYYYY'),-1),'MON')
    ) res
    from testdata
    STR
    PART
    PART_DATE
    RES
    GL~1001~157747~FEB-13~CREDIT~A~N~USD~NULL~
    FEB
    02/01/2013
    GL~1001~157747~JAN-13~CREDIT~A~N~USD~NULL~
    with year included
    with testdata as (
    select 'GL~1001~157747~JAN-13~CREDIT~A~N~USD~NULL~' str from dual
    select
    str
    ,regexp_substr(str, '[[:alpha:]]{3}-\d{2}') part
    ,to_date(regexp_substr(str, '[[:alpha:]]{3}-\d{2}'), 'MON-YY') part_date
    ,replace (str
             ,regexp_substr(str, '[[:alpha:]]{3}-\d{2}')
             ,to_char(add_months(to_date(regexp_substr(str, '[[:alpha:]]{3}-\d{2}'), 'MON-YY'),-1),'MON-YY')
    ) res
    from testdata
    STR
    PART
    PART_DATE
    RES
    GL~1001~157747~JAN-13~CREDIT~A~N~USD~NULL~
    JAN-13
    01/01/2013
    GL~1001~157747~DEC-12~CREDIT~A~N~USD~NULL~
    Message was edited by: chris227 year included

  • Cannot copy and paste words between EBS and other applications

    hi,every one
    I can't copy and paste word between Oracle EBS and other applications(such as MSword,excel) on a windows client.
    the version of EBS is 11.59 and jinitiator, 1.1.8.16
    has anyone ever encountered such problem and know how to resolve it?
    thank you in advance
    Message was edited by:
    user466827

    Download the appltop.cer from the APPS server to the local Machine
    Cd C:\Program Files\Oracle\JInitiator 1.1.8.16\bin
    ftp <IP Address>
    bi
    cd /apps/oraprod/prodappl/admin
    get appltop.cer
    bye
    Register that to the local identitydb.obj
    Cd C:\Program Files\Oracle\JInitiator 1.1.8.16\bin
    javakey c <name_it> true (creates a new trusted applet called )
    ( <name_it> in identitydb.obj )
    javakey ic <name_it> appltop.cer (signs the new <name_it> trusted applet)
    ( with the new certificate appltop.cer )
    javakey -l (will display your new trusted applet that has been signed)
    (With the appropriate digital certificate file of the)
    (Instance you wish to connect to. )
    Clear The Browser Cache
    Clear Jcache
    Restart the Browser Session.
    Regards,
    Prasanna
    [email protected]

  • Report to Find different between PCR & Schemas

    hi guru's,
    Can Any tell me the Report to Find different between PCR & Schemas in Two Clients,(For examle from 4.7 to 6.0)
    Regards,
    Bala

    Hi Bala,
    The following link will help you.
    PCR and SCHEMAS
    Thanks & Regards,
    Sandip Biswas

  • Finding difference between 2 databases

    Hi Folks,
    I have the following problem:
    I have 2 databases, database old, database new. Database new has modified/removed/added/inserted rows. Also columns in the db can also be modified. So what I have to do is to find the set of SQL statements which if I execute on database old, will make database old same as database new. Modification is only in data, not triggers etc.,
    I have explained my manager that this is not very easy to implement. Even finding difference between 2 DB is not trivial. Do you guys have any suggestion for me? whether in terms of implementing it or even convincing my boss is fine :)
    Are there any open source tools to do this? I am in big trouble now :(
    Thanks,

    Unless there is some other goal that you have not mentioned this is fairly easy.
    Just delete all the tables from the old database using SQL delete tables and then create new tables and populate them with data from the new database.
    Your SQL is basically just a serialization of the data in your new database.
    Anything else that you could do, such as calculating the differences from the one database to the other, and then creating a minimal edit list that will make the least possible number of changes must be weighed against the time it will take to write the code to compute the differences, the time it will take to debug the code and convince yourself that it is doing the right thing, and the time it will take to actually run.

  • Find no numbers  characters in a string

    HI, how i can find no numbers characters in a string
    By example.
    '45125454564#4545'.
    I only want to know if the string contains no number characters or not, i dont want to know the character '#'.
    Is there a function module for doing that?
    Thanks

    You can try:
    NUMERIC_CHECK
    OR
    IF var CO '0123456789'.
    ENDIF.

  • How to find MATCH count for #  in a String

    Hi all,
    How to find MATCH count for #  in a String.
    Ex:  6170#0400-0002-00#API3PT#AL#AUST#DEVE#KG#100.00#100.00#100.00#0.00##10.20
    Regards,
    Balavardhan.K

    >
    balavardhan k wrote:
    > I have used below syntax to find count but it is not returning the value and SY-SUBRC  = 4.
    >
    >
    > Data : l_text type string.
    >
    > l_text = '6170#0400-0002-00#API3PT#AL#AUST#DEVE#KG#100.00#100.00#100.00#0.00##10.20'.
    >
    >
    > FIND ALL OCCURRENCES OF '#' IN L_TEXT MATCH COUNT mcnt .
    Then it's not a # but possible a horizontal tab-sign.
    Do a find on cl_abap_char_utilities=>horizontal_tab instead.
    Edited by: Maen Anachronos on Nov 23, 2010 2:48 PM

  • Script to find word stacks in InDesign

    CS6, InDesign -- I've been looking for a proofing script that finds word & letter stacks and highlights items found & would be easily removed once items have been reconciled.

    While this scripting forum is a great place to get scripting help, it's also very easy to misuse it. Please bear in mind that for most (if not all) of the participants here, writing scripts is a source of income. If someone writes a particularly useful script, don't be shy to offer money (privately)! Also, please do not expect that complete scripts will be written for you (although in many cases they will be). If you are a novice scripter and show an interest in learning, you will generally find that the help you recieve will be much more positive.
    Here's a short list of "Dos" and "Don'ts" to keep in mind...
    Do ask for help in automating your work in InDesign, but Don't expect a full solution for free.
    Do show an interest in learning, and people will probably try to help you, butDon't ask for other people to solve all your problems for you.
    If you need a script written for you, Do ask if someone is available to write one for pay, but Don't keep such an issue on the forum. Work it out off the forum please.
    Please Do thank others who spend the  time to solve your issues, and pleaseDon't expect every issue to be solved on a public forum. Many solutions have  taken a lot of programming time to work out, and it's not reasonable to  expect such solutions to be given away for free.
    Please Do give code examples to help other people, but please Don't pass off others code as you own!
    Please Do make a note in the topic of a new thread of what language you are using as well as the version number that you are using such as: [JS][CS3].
    Please Don't branch off a discussion in the middle to a new topic -- please start a new one!
    Please Don't start two discussions on one topic -- it makes it very confusing!

  • Underlining just the word(s) in selected text string

    How do I get InDesign 2 or 3 to underline just the individual words selected and NOT the spaces?
    We work with legal documents and we have to style them exactly the way the judge has indicated (some underline everything, some just the words). This can become a time consuming endeavor when there are multi-worded court cases cited and sometimes over one hundred cites within one document.
    This was quick and easy under Quark, either from the control palette (click of a button) or the keyboard shortcut (Apple + shift + W). This shortcut closes the document in InDesign (even though the keyboard shortcut for that is supposed to be just Apple + W, both do the same thing). I could reassign the shortcut if I could find the action to link it too (but can't find the action even mentioned in the Help or the forums).
    Have checked under the Underline Options dialog, but there isn't anything there that would solve this problem.
    If there isn't a direct way to do it in InDesign, is there some sort of plug-in available that anyone knows about?
    Thanks in advance.
    LRP2

    I don't believe there's a direct way to do it in Indesign. There are some shortcuts that help.
    In CS4 you can set up a GREP search to find Words, set Change Format to change "basic character format" to include underline, then do a replace all in selection. You can set up keyboard shortcuts for some of this, but a script would be even more convenient.
    Unfortunately, with the normal "Find" function, the "character" wildcard also seems to find spaces, and there isn't a "whole word" wildcard, so this won't work in CS2 or CS3.
    The best I can think of at the moment is: Underline the whole text. Set Find What to find spaces (^w), leave Change To blank but in the Change Format box, turn off underline on Basic Character Formatting. Close the dialog box. Then, placing the cursor at the beginning, press shift-F3 (the standard shortcut for "Replace with Change To text and find next") for each space in the sentence. You can zip through the section fairly quickly.
    This is really a job for scripting -- the script should change all characters in the selection to underline, then change all white space characters in the selection back to non-underline. Scripts can be assigned a keyboard shortcut for ultimate convenience.
    Rodney

  • How do I locate non picture files and location? I'm getting low memory and can't find word,PDF etc

    how do I locate non picture files and location? I'm getting low memory and can't find word,PDF etc

    iPads don't have a filesystem like a computer, Files of that nature must be associated with an App and reside inside that particular App's file space.  So the way to find them is to open the App that opens that file type and look in its file or document list for them.

Maybe you are looking for

  • Satellite L505D-ES5025microphone issues please help me

    When ever I try to video chat my friends on the other end hear a high pitched screaming sound and my voice is very soft. When I record video I have the same issue with the sound. I have no idea how to fix it, or if I can fix it. Anyone know what the

  • How do I delete photos in iPhoto

    how do I delete photos in iPhoto?

  • Transferring info. from my old iPhone 4s to iPhone 5c but now my iPhone 5c is stuck on the connect to itunes screen

    I was in the process of backing up my iPhone 5c when iTunes asked me if I'd like to update my iPhone. I agreed but I guess there was a problem when updating because it showed an error screen then everything stopped. Now my iPhone 5c is stuck on the c

  • Reading ZIP files

    Is it possible to read content of ZIP files. Iam using ORACLE forms 6i. In our company, we are creating a zip file with two folder src and lib, where SRC contains FMB files abd LIB contains PLLfiles.Now i want to know whether instead of us seeing the

  • Wow-- What a Temp Drop!! Is it real??

    I would love to hear people's thoughts on this. A few months ago I put together an Athlon 64 3400+ and a MSI K8T FISR with a Thermalright XP-120 HS and Vantec Stealth 120mm fan in a Lian Li PC-65 aluminum case (4 built in case fans) and an Antec Neop