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();

Similar Messages

  • 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

  • Help me in writing ajax string search from database

    {noformat}*hi everybody,
    please send me a ajax with jsp application
    suppose i enter a word in text area ajax will populate/suggest all string from database ,who started
    from that entering character(s).like a google string search.
    please send full source code
    *{noformat}

    shadab_think_globally wrote:
    {noformat}*hi everybody,
    please send me a ajax with jsp application
    suppose i enter a word in text area ajax will populate/suggest all string from database ,who started
    from that entering character(s).like a google string search.
    please send full source code
    *{noformat}how about you do it yourself?

  • Faster string search options

    Hi
    I am an intern at a mobile technology firm assigned the job of enhancing the search performance of a tool, which is coded completely in java. This tool, along with other features basically searches for the substring in a string array by using the string.indexof() method which is very slow, since i am dealing with vast amount of data..
    Now the last two weeks all I did was try and understand the massive code. These are the alternatives I came up with. I could do with suggestions about the feasibilities of these ideas.. or any new suggestions are welcome..
    1. are there any faster ways instead of string.indexof() that i can use to do my string search?
    2. How about replacing this indexof() method with a faster search algorithm? something like boyer-moore for example??
    3. will using a the .nio package instead of .io package work???
    4. how about completely scrapping this string search and taking in the data from input stream as integer format.. and then doing the comparisons??
    thanks
    mahima

    yumjay wrote:
    1. are there any faster ways instead of string.indexof() that i can use to do my string search?You seem to have found one in section 2.
    2. How about replacing this indexof() method with a faster search algorithm? something like boyer-moore for example?? Well obviously you can't override or replace String's indexOf, but you could certainly change the code to use a different algorithm. What's stopping you?
    3. will using a the .nio package instead of .io package work??? Not sure, there may be virtue in some of the memory mapping additions, but I don't really know your requirements or situation.
    4. how about completely scrapping this string search and taking in the data from input stream as integer format.. and then doing the comparisons?? The string search is essentially doing integer comparisons on data 16 bits at a time (that's the width of a char). So first, remember that the int returned by InputStream.read() isn't really an int but a byte stuffed into an int (so they can return -1 on EOS). That said, you might experience a performance gain if you put the data into ints or longs (depending on your computer architecture) and then use something like boyer-moore, because your computer can likely do comparisons of two bytes, chars, shorts, ints (and perhaps even longs on a 64-bit architecture) in the exact same amount of time. They're probably even the same machine instruction. You also wouldn't therefore have to decode the input data into a string either. But you'd have to encode your search string into integers. So yeah you could potentially squeeze a bit more speed, not likely more than 50% though.

  • Exact string search

    i was wondering if there was a way to do an exact string search in a document.
    If i have a document that has punctuation i want to be able to find the document only if i query whith an exact string match, including stopwords and punctuations.
    if the query is
    select *
    from documents1
    where contains(OBJECT_VALUE,'{hello, world}') > 0
    I want only to return the documents that have exactly "hello, world" whith the comma included.
    If i add the comma to printjoins, it would work, But when i query for only "hello" it wont match "hello, world"
    basicaly im looking for something that does a normal search but then check if the exact string is in the match area.

    Try this
    select substr(&P, (INSTR(&P, CHR('32'), 1))+1, (INSTR(&P, CHR('32'), 1)))
    from dual
    &p is a variable
    I am sure this will help you in any of case
    chr(32) will return space, If you have any other thing except space then you just replace 32 with that ascii code. Such as for
    1(we)2 then query will be
    select substr(&P, (INSTR(&P, CHR('40'), 1))+1, (INSTR(&P, CHR('41'), 1)))
    from dual
    Try it and tell is it working fine

  • Like %, string search

    Hi all,
    I am making a application in which there is string search but i dont know how to find a solution.
    For example in sql, there is (like %) expression to find similar words. But in java how can I do that.
    For instance word1 = mehmet, word2 = mehemet.
    How can i do it?
    Thanks...

    regerybets wrote:
    Hi all,
    I am making a application in which there is string search but i dont know how to find a solution.
    For example in sql, there is (like %) expression to find similar words. But in java how can I do that.
    For instance word1 = mehmet, word2 = mehemet.
    How can i do it?
    Thanks...Sounds like a job for Levenshtein. Apache has an implementation in their Commons-Lang API:
    import org.apache.commons.lang.StringUtils;
    public class LevenshteinDemo {
        public static final int MINIMUM_LIKE_DISTANCE = 4;
        public static boolean like(String wordA, String wordB) {
            return like(wordA, wordB, MINIMUM_LIKE_DISTANCE);
        public static boolean like(String wordA, String wordB, int permittedDistance) {
            return StringUtils.getLevenshteinDistance(wordA, wordB) <= permittedDistance;
        public static void main(String[] args) {
            String a = "mehmet";
            String b = "mehemet";
            String c = "ambulance";
            String d = "meehemeet";
            String e = "mhmt";
            System.out.println(like(a, b));
            System.out.println(like(a, c));
            System.out.println(like(a, d));
            System.out.println(like(a, e));
    /* output:
                    true
                    false
                    true
                    true
    */Download it here: [http://commons.apache.org/downloads/download_lang.cgi], stick the file commons-lang-2.4.jar in your classpath and the snippet above will compile. Of course, you may want to make permittedDistance variable depending on the size of the input words. Now it will only work for small strings/words, not larger chunks of text.

  • Approximate string search

    Hi everyone,
    If anyone here is interested in approximate string search algorithms, take a look at this prototype: http://scientechs.com/servlet/smartsearch.test.ApproxiMatchServlet . Keyword DB was compiled from the list of canadian business names and has right now ~200K of words, so don't expect to find every english word there.
    Source code would be uploaded to sourceforge soon (smartsearch.sourceforge.net). If anyone wants to participate in improving the project, drop a note. All feedback is welcome.

    From the description:
    "Approximate string search algorithm implementation (the algorithm was developed from the scratch, so it is NOT an implementation of existing algorithms), written in Java and runs under any OS that supports Java2 platform."
    I know there are a number of approximate string matching out there. My question is how does your algorithm relate to the other ones?
    I tried keyword apple, so it seems there is more work to do, but at least it worked.

  • Is there any API available to do string search and replace?

    as above?

    For simple string searching have a look at java.util.StringTokenizer.
    Regular Expressions are included in v1.4.
    Have there a look at the String class itself and the new java.util.regex package.
    Greets
    Puce

  • String search in SAP Script and Smartforms

    Hi All,
    We have an urgent requirement where we need to search for a character string in all SAP Scripts and Smartforms in our system.
    It would also help if we can get the names of programs/function modules which are internally generated for the same.
    Any pointers on the same would be helpful.
    Regards,
    Saurabh

    You can create a variable window in the main window.
    You can restrict the last item of the main window by varying the size of main window. In your wite-form ,
    CALL FUNCTION 'WRITE_FORM'
          EXPORTING
             element                  = 'ITEM'
          function                 = 'SET'
          type                     = 'BODY'
          window                   = 'MAIN'
          EXCEPTIONS
            element                  = 1
            function                 = 2
            type                     = 3
            unopened                 = 4
            unstarted                = 5
            window                   = 6
            bad_pageformat_for_print = 7
            spool_error              = 8
            codepage                 = 9
            OTHERS                   = 10.
        IF sy-subrc <> 0.
    DO this. in the bottom of the main window, create a variable window.
    you can add your text in the variable window inside main window.
    it will be displayed just after the item ends.
    Reagrds,
    Pritha.
    Message was edited by:
            Pritha Agrawal

  • Why String Search in not working in ADF.?

    Hi,
        I've created application in ADF with Search Options. Search Operation is working for all the Integer Values in that page but its not working for String Values.
    I dont know why its not able to search String Values.
    My AppModule bean Code :
                    package model.portfolio.portfolio.am;
    import model.portfolio.portfolio.am.common.PortfolioAppModuleAM;
    import model.portfolio.portfolio.view.ResourceViewChildObjImpl;
    import oracle.jbo.VariableValueManager;
    import oracle.jbo.ViewCriteria;
    import oracle.jbo.server.ApplicationModuleImpl;
    import oracle.jbo.server.ViewLinkImpl;
    import oracle.jbo.server.ViewObjectImpl;
    public class PortfolioAppModuleAMImpl extends ApplicationModuleImpl implements PortfolioAppModuleAM {
         * This is the default constructor (do not remove).
        public PortfolioAppModuleAMImpl() {
        public void applyVCforGlobalSearchPortfolios(String theString){
            ViewObjectImpl vo = getPortfolio1();
            ViewCriteria vc = vo.getViewCriteria("PortfolioVOCriteria");
            System.out.println("On Criteria");
            vc.resetCriteria();
            VariableValueManager vvm = vc.ensureVariableManager();
            System.out.println("On String");
            vvm.setVariableValue("globalSearchString", theString);
            System.out.println("After String");
            vo.applyViewCriteria(vc,true);
            vo.executeQuery();
    *All Getters and Setter of all VO and VLs****
    My Query created in View Criteria :
    ( (UPPER(SHORTNAME) LIKE UPPER( :globalSearchString || '%') ) OR (UPPER(DESCRIPTION) LIKE UPPER( :globalSearchString || '%') ) AND (PROGRAMMES_COUNT = :globalSearchString ) OR (KK_COUNT = :globalSearchString ) OR (KPI_KRA_VALUE = :globalSearchString ) )
    One more interesting thing in After Creating the View Criteria If i try to Test this Query, Its giving me error msg as
    "Cannot complete query to determine the view attributes.  Either the query is invalid or timeout occurs.  Please revise the query or create the view attributes manually.
    "com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':globalSearchString || '%') ) OR (UPPER(QRSLT.DESCRIPTION) LIKE UPPER( :globalSe' at line 1"
    I don know why... Can somebody please help me?
    Im using Jdev 12C

    Binding variables will be different from oracle database and My Sql database.
    Oracle database use this (:) for defining bindVariable but in My Sql use this (?)
    Try to remove the view criteria which you define in View Object and you can make it programmatically like this:
        ViewObject vo = getPortfolio1();
        ViewCriteria vc = vo.createViewCriteria();
        ViewCriteriaRow vcr = vc.createViewCriteriaRow();
        vcr.setAttribute("Attribute1", value);
        vcr.setAttribute("Attribute2", value);
        vc.add(vcr);
        vo.applyViewCriteria(vc);
        vo.executeQuery();

  • Using Right {field, 5} in string search

    Hello,
    I have an array with the following data  xyz5 = 'US 10411', 'US 10421', 'US 10431', 'US 10441'
    The SN field is 5 character length with data such as 10411, 10421 10441 etc..
    How do I search for the last 5 digits of each of the data in the array?
    myaop6report.RecordSelectionFormula = "{aop5.SN}in right {[" & xyz5 & "],5}"
    Thankls,
    Victor

    Hi Victor,
    To search for the SN database field in the array, you can create a Record Selection Formula like:
           (" " + + ",") in (Join(YourArray,",")+",")
    Where should be replaced by your database fields that contains the SN number, and where YourArray is your array.
    The formula convert the array in a string seperated by commas.
    Then add a comma to your database field as well as a space in front. Finally it compare the SN fields to the long string.
    So for example if the database fields SN contains 10431, then the value we will search is: 
    10431,
    The array will now be a long string like:
    US 10411, US 10421, US 10431, US 10441,
    And it will look for the value 10431, in the string.
    The comma at the end and the space at the beginning it's to ensure it doesn't find any values that may exist within another one. It shouldn't be an issue in your case since it is always going to be equal to 5 characters for the SN value, but just in case it doesn't, we do not want to return 1043133 when we are searching for only 10431.
    Regards,
    Patrick

  • Quick Question on String Searches

    I'm about to write a small program to find a target string in any file format, then display the target string and the first 200 characters before and 200 characters after the target string to the console. I want to use OOP, using main() for testing purposes only, but I'm not sure of the best way to approach this. Should I use the store() and load() methods from Properties or just use indexOf()? Any thoughts, folks? Thanks.

    If fyou are going to be searching in any file format (including binary files such as Word docs) then you can't really use the indexOf or the Properties class (I am not sure what your intentions were with the Properties class, but using it requires a particular file format).
    Just off the top of my head, I would suggest using a RandomAccessFile and seeking around, reading data into buffers when you find what you want. To me, this isn't exactly a job for OOP, at least at its guts. You can use OOP to come up with a design - perhaps using specific "Searchers" tuned to particular file formats, and then have a driver class that determines, at runtime, which Searcher class to use for a given file. But again, that's just off the top of my head.
    Good Luck
    Lee

  • 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.

  • String searching algorithm needed.

    Hi. Am trying to make a simple text editor that includes a search capability. When there is some text on a TextArea, the user can search through the string for some text. So far I have managed the part that the text being searched for is found but when the text being searched for is not present am having trouble.
    Also, I need to be able to highlight or make bold the string if it has been found. Can somebody please help? Thanks.

    The basic idea I use to search is, I have an InputBox object from the Javabook package (http://www.drcaffeine.com/) that gets the string. Then I get the length of that string and that of the main text and use substring() method to search through the main string, the search times decided by the length of the main string. After it has found, I have managed to convert the string ( if found ) to capitals but am defeated to highlight or bold it. Am also out of ideas on what to do if the search string is not found. Am getting errors.

  • 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.

Maybe you are looking for

  • How can I use two single-dimensional arrays-one for the titles and array

    I want to Use two single-dimensional arrays-one for the titles and one for the ID Could everyone help me how can i write the code for it? Flower public class Video public static void main(String[] args) throws Exception int[][] ID = { {145,147,148},

  • Help with Movie Clips

    Hi - I'm having a problem with my movie clips playing simultaneously and cannot, for the life of me, figure out what I have done wrong. I'm new to flash, so I may have set something up incorrectly, but here's what I have so far: 11 layers, total: 1 l

  • RAW images (free database or other) for explore

    Hi, At this moment I have a simple camera Panasonic DMC-FZ8. Before buying a step better I am curious to see the quality-difference of RAW-images of some other cameras like Nikon DX or Canon etc. And (not for buying, but to see the difference) may be

  • How do i fix error 1303

    I can't downloan Adobe Reader XI.  I get error msg 1303.  I am logged in as the admisistrator.  Help, please

  • "no such file or directory"--but file's listed with ls -al

    How do you delete a file which is listed with "ls -al" in Terminal, but when you try to 'sudo rm' it, you get "no such file or directory"? The file in question is a troublesome temporary Excel spreadsheet file--something like "~$TroublesomeFile.xlsx"