Multiple string search

I'm having problems trying to search a file for various strings. Once the first search string has been found,
I need to search for another string (within the first search) , and then process the input lines. The code below works for the first search, but my efforts to incorpate a second search string fail. Can anyone help please?
Rob
StringBuffer buf = new StringBuffer();
buf.append("//");
buf.append(jobStep);
search = buf.toString();
buf.setLength(0);
String infile = "//INFILE";
String line = null;
BufferedReader reader = new BufferedReader(new InputStreamReader(inS));
int pos = -1;
int pos1 = -1;
int count = 0;
String inputLine;
while ((inputLine = reader.readLine()) != null) {
for (; true; ) {
pos = inputLine.indexOf(search, pos + 1);
if (pos >= 0) {
out.println( "step = " + inputLine + "<br>" ); *** code works to here , now I've found jobStep, need to find string 'infile'
count++;
else {
break;

You could put your search strings in a collection, such as an array or Vector, and then get each search string, as needed.

Similar Messages

  • Finding multiple strings in a text file and deleting the entire line

    Get-Content c:\output-Copy.txt | Where-Object {$_ -notmatch 'something1', 'something2', 'something3', 'something4' } | Set-Content temp.txt
    Above is the program that when it has 1 argument in the -notmatch part will find the specific string and delete the entire line. I need to be able to use multiple strings for my search, I am totally drawing a blank on this and I know its something REALLY
    simple but my brain is fried. The above code will work IF i only leave 'something1' and delete the rest. I need to find MULTIPLE matches and remove them all at once, what is a good way to accomplish this.

    You can use an alternating regex, like this:
    Get-Content c:\output-Copy.txt |
    Where-Object {$_ -notmatch 'something1|something2|something3|something4' } |
    Set-Content temp.txt
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • PSE8 Oraganizer, multiple tag search AND OR

    I'm trying to figure out what logic multiple tag searches is using. Just when I think I have it figured out I find something different.
    For instance the People and Places categories behave differently.  Selecting multiple tags within the same People category behaves like a Boolean AND. Multiple tags in the Places category act as an OR. Selecting a subcategory in the People category will select all the keywords in the sub-category and perform an OR. Selecting a sub-category as an Exclude will only exclude the sub-category as a keyword. It does nothing with the keywords in the sub-category.
    I haven't finished testing all the other possiblities with the other categories, like; Events, Other, Animals.
    I guess my question is; Where is the Adobe full description on how this works?
    My request would be to have the ability to construct a more advanced Boolean expression. Perhaps in a manual mode by typing in a Boolean string.
    Thanks,  -phil

    Thanks for the reply John,
    I doubled checked multiple tags selected in either the People category or the Places category and it is doing an AND in People and an OR in Places.
    Here's my test:
    People category with 2 keywords; Phil, Kristi.
    Phil selected, returns 223 items with Phil in them
    Kristi selected returns 510 items with Kristi in them
    Phil and Kristi selected returns 109 items with Phil AND Kristi tags applied to them.
    Places category with 2 keywords Aruba, Bad Axe
    Aruba selected, returns 50 items, looks like all my Aruba shots
    Bad Axe selected, returns 26 items, looks all my Bad Axe shots
    Aruba and Bad Axe selected, returns 76 items, looks like all my images with Aruba OR Bad Axe shots.
    These catagories came defined with PSE8. Must be something built in??. I quickly looked at my other Categories and they all appear to be doing OR logic with mukltiple keywords. Looks like it's just the People category that behaves as an AND.
    In Preferences the, "Show Closely Matching Sets for Searches" is unchecked. When I check this it does change the behavior. For my people test it now returns 624 with Phil and Kristi selected. The Aruba, Bad Axe selection returned the same number.
    While testing this and writing it down a thought came to me. With my People tags there are images that are tagged with multiple People tags. Like pictures of Kristi and Phil together have both tags. However, my Places tags never have more than one tag applied. I looked in my Pets category and it is behaving like my People category because it will have multiple pet keywords in some photos.
    So, in conclusion, the program is looking at how you've used the keywords. If there are images in the catalog that have multiple keywords from a particular Category tagged to them it will act as an AND search when you select multiple tags from that Category. On the other hand, if there are no images with the multiple tags applied to them then the search behaves as an OR when you select those tags. So it just depends.
    One more example. When I select Phil and Kristi and Aruba, I get back the 6 shots that have those tags. When I select Phil and Kristi and Bad Axe I get back 650 shots. I would rather get back 0 because there are no shots that have all 3 of those tags. The preference is unchecked for the closely match option.
    -phil

  • Does endeca support multiple keyword search

    Am new to endeca.
    Does endeca support multiple keyword search in atg crs.
    an eg can we search for "shirt,shoes" and get results for both

    How specifically to implement this depends on how you are querying Endeca.  With a simple URL parameter query using the UrlENEQuery object you would set the parameter of Ntx=mode+matchany, and if you were using the ENEQuery class you would set it like:
    ENEQuery query = new ENEQuery();
    ERecSearchList searchList = new ERecSearchList();
    String matchMode = searchTerms.contains(",") ? "mode+matchany" : "mode+matchallpartial";
    ERecSearch search = new ERecSearch( "your-search-interface", searchTerms, matchMode );
    searchList.add( search );
    query.setNavERecSearches( searchList );
    If you are using the Assembler Service, you can include the Ntx parameter in the call, so you would wrap your call with some conditional logic, e.g.:
    String serviceCall = null;
    if( searchTerms.contains(",") ) {
       serviceCall = "assember/xml/browse?Ntt=shirt,shoes&Ntx=mode+matchany";
    } else {
      serviceCall = "assember/xml/browse?Ntt=shirt,shoes&Ntx=mode+matchallpartial";
    If you are using the Content Assembler API within your application, it will depend on how you are invoking it but some of the above should help you customise appropriately.
    HTH
    Michael

  • Match pattern for multiple strings in labVIEW

    I want to include multiple strings for matching in the regular expression for pattern matching.I tried using the or option and (|)
    eg:cat|dog|mouse
    If the string contains any of these it should show a match.
    Is it possible in labview or do i need to use multiple patch mattern functions to achieve this?

    Match Regular Expression function will do.
    You can search for multiple strings using | operator. This function will return the match of any one of the specified strings seperated by | operator

  • Efficient string search into files

    Hello, i wrote an application that search a string into several files. At the moment i perform the search looping each files, opening them with new BufferedReader(new FileReader), using .readLine() method to get each line and .indexOf >= 0 to check if the line contains the string to search.
    Is there a more efficient way to do it? Maybe using Scanner class or what else? HasMap? thanks in advance for the replies

    To search for a string in a file you do not have much choice but to read the file and search the characters for the given string.
    If you only need to find the first occurrence of the string then obviously you want to stop reading the file when you have found it (unless you need to do something with the rest of the file). Using a large buffer size might help the reading efficiency of the process. You might check out java.nio for some more efficient ways of reading streams in general.
    I don't see how a HashMap would help with this process unless you need do something along the lines of counting occurrences of multiple strings.
    If all you want to do is search for a string then I am not sure what you would gain using the Scanner class.

  • How can I send multiple string commands into a VISA write?

    Hi Fellow LabVIEW users
    I am very new to LabVIEW (2.5 months) so please forgive me if my lingo is not up to par.
    How can I send multiple string commands to a VISA write. For example each string command looks like this
    1) 3A00 0000 0000 FFFF FFFF FFFF 0000 0000 FF00 0000 0000 0000 0000 0033 (Scenario 1)
    2) 3A01 0000 0000 FFFF FFFF FFFF 0000 0000 FF00 0000 0000 0000 0000 0034 (Scenario 2)
    3) 3A01 0000 0000 33FF FFFF FFFF 0000 0000 FF00 0000 0000 0000 0000 0067 (Scenario 3).
    and so on and so forth. And there are a number of scenarios.
    Each String scenario will give a different string output which will be interpreted differently in the front panel.
    Right now I have to manually change the string commands on the front panel to give me the desired output. How can I do this without manually changing the commands i.e. hard coding each scenario into the block diagram?
    Thanks, any feedback will help.
    mhaque

    Please stick to your original post.

  • How do I input multiple string constants into VISA Write

    I am trying to put in multiple string commands into VISA Write to control a motor arm. However, when I use "concatenate strings" to link together my multiple string constants, only the first command is executed, and neglects the other commands below it. Should I be using something other then "concatenate strings" or do I need to use a delay so that the next command executes when the one before it is finished? Help.

    Concatenate strings should work or just use one string constant with multiple lines. The problem you're having could be that the instrument requires some sort of delay but without details on the instrument, only you or the vendor can answer that. Some instruments will have a queue and others won't. The other possiblity is that you need some kind of termination character between commands. This might be a carriage return for a serial instrument or the ; character for a GPIB one. Check the instrument manual or provide the make and model and maybe someone here has some experience with it.

  • Problem in String Search using OKAPI in 9i Lite

    We are creating an Symbian EPOC application using Oracle 9iLite in stand-alone mode. We have managed to create a C++ program that creates an Oracle database on the Nokia Communicator 9210.
    The problem is that a string search returns either null or all of the searched records, ie. it does not work.
    The code below should do the string search and return the strings that match the given keyword. Any idea why this is not working? We are using OKAPI.
    TempCond[0].Operator = OK_GT;
    TempCond[0].AttrPos = KEYWORDREFERENCE_INDEX_FOR_KEYWORD;
    TempCond[0].AttrVal.BufPtr = (unsigned char*) szGivenKeyword;
    TempCond[0].AttrVal.BufSize = OK_NEW_ARRAY | strlen szGivenKeyword);
    TempCond[0].AttrVal.Indicator=1;
    TempCond[0].Collate=0;
    TempCond[0].Connective=OK_AND;
    // Iterate through the entire group, extracting the key data
    //(whatever the key may be) and the object reference, and
    // append to the end of the array.
    e = okCreateIterator( iEnv,
    iEbmgKeywordReferenceGroupRef,
    iEbmgKeywordReferenceClassRef,
    FALSE,
    1,
    TempCond,
    20,
    0,
    NULL,
    &iter
    Thanks for any help you may provide.

    I am sorry, this is not an answer to your question but a little help from you is well appeciated.
    I have just started exploring oracle 9i Lite to develop apps. on Palm and WinCE using OKAPI but the documentation does not seem enough. Is there some book or sample programs available that demonstrate OKAPI to develop form based apps ? CodeWarrior and Satellite Forms are not good when someone wants to try writing demp app.
    Thanks,
    Ashish

  • String search

    i hI have a string "1234, abcdef, bbbbb"
    How do one get/search for the "abcdef" or "bbbb" out of the string using substring?
    If anyone has source code or references (for similar code) searching for "abcdef�(normally text enter in a text field that will be used to search through a string) It would be appreciated

    // This might help!
    String search = "test";
    Pattern pattern = Pattern.compile(".*" +search +".*");
    boolean test = pattern.matcher(testString).matches();

  • Multiple Keyword Searching

    I am having trouble doing multiple keyword searches in aperture. Say for instance I tagged a photo with the word "Bob" and then with the word "Park". If I search for just Bob or just Park, I get all photos tagged with one or the other keyword. But if type into the keyword search bar: Bob, Park. No photos come up. I have tried several different ways of searching keywords. Anyone having the same problem or know how to fix it?

    The same is written in the [Aperture3 User Manual|http://documentation.apple.com/en/aperture/usermanual/index.html#chapter =14%26section=7%26tasks=true]; it doesn't work in Ap3 either. (The comma seems to be taken a literal character, not as a separator.)
    Ap3 lets one add additional filter rules, so that one could have two Text rules. (I never used Ap2.)
    Ap3 limits the keyword list to those keywords present in the currently selected container(s). So to at least check what you are doing -- if Ap2 does the same -- select or filter to a number of images with just a handful of keywords total, and see what you find out.
    Nice to see the sun for once.

  • Help with deleting multiple strings from file.......

    I am trying to delete the same string that may appear multiple times in the file. Here is the output to the screen. Here is the code. I have been researching the delete method it says that I have to start at an index position in the string but how would I find out where the multiples strings reside in the file? I am getting the feeling that it won't work for my purpose..???? I am trying to delete all ot the strings "a string of data3" from the file.
    Output
    C:\TestRead>java StringDelete
    Temp String file_data-------- a string of data3a string of data2a string of data
    1a string of data3a string of data2a string of data1a string of data3
    Just A Blank Line
    Just A Blank Line
    Just A Blank Line
    String toDelete-------- a string of data3
    Just A Blank Line
    Just A Blank Line
    Just A Blank Line
    String toDelete-------- a string of data2
    Just A Blank Line
    Just A Blank Line
    Just A Blank Line
    String toDelete-------- a string of data1
    Just A Blank Line
    Just A Blank Line
    Just A Blank Line
    String toDelete-------- a string of data3
    Just A Blank Line
    Just A Blank Line
    Just A Blank Line
    String toDelete-------- a string of data2
    Just A Blank Line
    Just A Blank Line
    Just A Blank Line
    String toDelete-------- a string of data1
    Just A Blank Line
    Just A Blank Line
    Just A Blank Line
    String toDelete-------- a string of data3
    Just A Blank Line
    Just A Blank Line
    Just A Blank Line
    Code:
    import java.io.*;
    public class StringDelete
    public static void main(String [] args)
    try
    FileInputStream fis = new FileInputStream("TestFile.txt");
    DataInputStream in = new DataInputStream(fis);
    StringBuffer file_data = new StringBuffer();
    while(in.available() > 0)
    String temp = in.readUTF(); // read in a string from the file
    file_data.append(temp); // append it to the buffer
    System.out.println("Temp String file_data-------- " + file_data);
    System.out.println("Just A Blank Line");
    System.out.println("Just A Blank Line");
    System.out.println("Just A Blank Line");
    boolean keepGoing = true;
    while(keepGoing)
    String toDelete = file_data.substring(0, "a string of data3".length());
    System.out.println("String toDelete-------- " + toDelete);
    System.out.println("Just A Blank Line");
    System.out.println("Just A Blank Line");
    System.out.println("Just A Blank Line");
    if(toDelete == null || toDelete.equals("") )
    keepGoing = false;
    else
    file_data.delete(0,"a string of data3".length());
    catch(IOException e)
    e.printStackTrace();

    Here is the output. I am trying to get each part to work before I go on to the next part that is why some code is commented out.
    I need help to know why string "a string of data3" is not deleted in the towrite string??
    Output:
    C:\TestRead>java NewStringDelete
    String v after remove [ &#9668;a string of data3 &#9668;a string of data2 &#9668;a string of data1
    &#9668;a string of data3 &#9668;a string of data2 &#9668;a string of data1 &#9668;a string of data3]
    String towrite after remove &#9668;a string of data3 &#9668;a string of data2 &#9668;a string of
    data1 &#9668;a string of data3 &#9668;a string of data2 &#9668;a string of data1 &#9668;a string of data
    3
    Code:
    import java.util.Vector;
    import java.io.*;
    public class NewStringDelete
         public static void main(String [] args)
              //String ls = System.getProperty("line.separator");
              //File file;
              Vector v=new Vector();
         try{
              BufferedReader br=new BufferedReader(new FileReader ("TestFile.txt"));
              String s;
              while ((s=br.readLine())!=null)
                   {v.addElement(new String(""+s));}
                        br.close();
         catch(IOException e)
                   e.printStackTrace();
    /*now you have a Vector containing String objects..*/
         String remove = ("a string of data3");
         String towrite="";
    System.out.println("String v after remove " + v);     
         for (int i=0; i<v.size();i++)
              String ss = (String)v.elementAt(i);
              if (ss.equalsIgnoreCase(remove)){continue;}
              //     towrite=towrite+ss+ls;
                   towrite=towrite+ss;
    System.out.println("");               
    System.out.println("");               
    System.out.println("String towrite after remove " + towrite);                    
    /*do filewrite*/
    //try{
    // FileWriter fw=new FileWriter(TestFile.txt);
    // fw.write(towrite);
    // fw.close();
    // catch(IOException e)
    //               e.printStackTrace();

  • Endeca:Multiple keyword search

    I have integrated atg application with endeca and i implemented multiple keyword search.Now i am getting combined results.For eg:if i search for ice and shampoo i am getting combined results for both.I want to separate the results based on the search term in the front end?Please help.I am  using atg10.1.2
    Thanks  in advance

    Hi KannanMN,
    We will be getting the meta data related to the record in the results list saying why that particular record matched and retrieved. Using this information, you can populate or separate the results to go into two different div containers in the front end.
    Hope this helps.
    Keep posting the updates or questions.
    Thanks,
    Gopinath Ramasamy

  • Multiple criteria search with 4 dropdown lists

    I want to perform a multiple criteria search on a MySQL
    database. Users should be able to use from 4 dropdown lists in a
    form only one criterium, all 4 of them or 2 or 3.
    Each used dropdown list gives a numeric variable: Fvar1 ...
    Fvar4. The variables from the dropdown lists used should be matched
    with numeric fields in the database: DBvar1...DBvar4
    The numeric variables from the dropdown lists that are not
    used, should be ignored.
    Example: a user selects a value in dropdown list 2 and 3 and
    does not use dropdown lists 1 and 4. Fvar1 and Fvar 4 should then
    be ignored for the search, that has to be performed with Fvar2 and
    Fvar3, who have to be matched with DBvar2 and DBvar3.
    Anyone who can help me out with the WHERE statement in my SQL
    query?
    Your help will be greatly appreciated.
    Erik

    Erik61 wrote:
    > I want to perform a multiple criteria search on a MySQL
    database. Users should
    > be able to use from 4 dropdown lists in a form only one
    criterium, all 4 of
    > them or 2 or 3.
    Start by using the Advanced Recordset dialog box to create a
    query that
    looks for all four variables. Then switch to Code view and
    start carving
    up the code created by Dreamweaver.
    The query will look something like this:
    $query_getProducts = sprintf("SELECT product_name, price
    FROM products
    WHERE prod_type = %s AND colour = %s AND size = %s AND range
    = %s
    ORDER BY price ASC",
    GetSQLValueString($var1_getProducts, "text"),
    GetSQLValueString($var2_getProducts, "text"),
    GetSQLValueString($var3_getProducts, "text"),
    GetSQLValueString($var4_getProducts, "text"));
    Change it like this:
    $query_getProducts = "SELECT product_name, price
    FROM products
    WHERE ";
    $where = false;
    if (!empty($_GET['prod_type')) {
    $query_getProducts .= sprintf("prod_type = %s ",
    GetSQLValueString($var1_getProducts, "text"));
    $where = true;
    if (!empty($_GET['colour'])) {
    if ($where) {
    $query_getProducts .= 'AND ';
    $query_getProducts .= sprintf('colour = %s ',
    GetSQLValueString($var2_getProducts, "text"));
    $where = true;
    if (!empty($_GET['size'])) {
    if ($where) {
    $query_getProducts .= 'AND ';
    $query_getProducts .= sprintf('size = %s ',
    GetSQLValueString($var3_getProducts, "text"));
    $where = true;
    if (!empty($_GET['range'])) {
    if ($where) {
    $query_getProducts .= 'AND ';
    $query_getProducts .= sprintf('range = %s',
    GetSQLValueString($var4_getProducts, "text"));
    That builds the query in stages using $where to decide
    whether to add
    "AND" in front of the second, third, and fourth variables.
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Split a multiline string from TextEdit into multiple strings

    Hi all,
    I have a small question. I have a string that comes from a multiline TextEdit used for comments. This string has to be split into multiple strings with max 72 chars. The wrapping is set to "hard".
    Can anybody help me on this?
    Thanks
    Francisco

    Hi Francisco,
    this is the complete code I tested, a bit ugly concerning the println etc... (****, not formatting here?):
    package com.btexx;
    import java.util.StringTokenizer;
    import com.sapportals.htmlb.Button;
    import com.sapportals.htmlb.Form;
    import com.sapportals.htmlb.TextEdit;
    import com.sapportals.htmlb.enum.TextWrapping;
    import com.sapportals.htmlb.event.Event;
    import com.sapportals.htmlb.rendering.IPageContext;
    import com.sapportals.htmlb.rendering.PageContextFactory;
    import com.sapportals.portal.prt.component.AbstractPortalComponent;
    import com.sapportals.portal.prt.component.IPortalComponentRequest;
    import com.sapportals.portal.prt.component.IPortalComponentResponse;
    public class TextEditExample extends AbstractPortalComponent
        public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
            IPageContext pageCtx = PageContextFactory.createPageContext(request, response);
            Event lastEvent = pageCtx.getCurrentEvent();
            if (lastEvent == null) {
                Form form = pageCtx.createFormDocument("myFormDocument");
                TextEdit te = new TextEdit("Edit_Text");
                te.setId("TextEditID");
                te.setText("Text to change - or just add text");
                te.setWrapping(TextWrapping.HARD);
                te.setTooltip("Edit and/or add text");
                te.setRows(10);
                te.setCols(72);
                form.addComponent(te);
                Button btn = new Button("MyButton");
                btn.setOnClick("react");
                form.addComponent(btn);
                pageCtx.render();
            } else {
                TextEdit te = (TextEdit) pageCtx.getComponentForId("TextEditID");
                String text = te.getText();
    //            for (int j = 0; j < text.length(); j++) {
    //                System.out.println(text.getBytes()[j] + " - " + text.substring(j, j+1));
                StringTokenizer st = new StringTokenizer(text, "nr");
                String[] texts = new String[st.countTokens()];
                while (st.hasMoreTokens()) {
                    System.out.println("Line : " + st.nextToken());
    I swear, I did not press Return within the TextEdit box, and after that, 13/10 appeared within the text. If just this code does not work the same on your machine, then it seems to be a bug in (your) htmlb (because my P/HF are the most actual, at least they have been yesterday).
    Hope it helps
    Detlev
    Message was edited by: Mark Finnern
    added the [code ] [/code ] (without the blanks)

Maybe you are looking for

  • How do I get an app back that I took off my iphone by removing it through my desktop?

    I removed the app garage band from my iphone 4 through my pc using itunes 11. I errased it from the large screen in my itunes that represented my iphone. usually, my apps would show up on the left hand side and I could sort by name and size etc. For

  • Changes made in the table not visible in the AM

    Hi, I have few validation that i need to conduct on the data that is modified in the table. The problem is that when i create a new VO instance in the AM method it does not show me the updated VO. Instead it shows me the VO before update. However, if

  • Transformation in ODI -  SQL command

    hello .. I would thank every body for helping out some people like me .. I create an interface and work successfully .. so I want to apply a filter on the source table .. my sours table1 has a column call ( price ) .. and there is some 0 on some reco

  • Bookmark system should remember the playl

    I listen to audio books a lot. Even if you just listen to music there are times where you want to stop listening to your current selection, save where your playback has gotten to and listen to something else for a while, then jump back to your previo

  • IPhoto is hanging

    I just installed iLife 08 and had iPhoto work the first time I opened it. It looked great. Now when I try to open the program it hangs with the spinning wheel of frustration. Also when I look at the hard drive I noticed that my folders from iPhoto 06