Match Certain word in a String

Hi all,
I'm actually doing a project regrading e-learning. And i'm suppose to create a set of questions for each topics using labview. So Is there any way that i can match certain word in the string to make sure that answer is correct? Cause i'm sure that every user that input answer will be different. Thus, I want to pick out main point as an answer. Is there anyway i can do it?? 
Really appreciate your help!!! 
Thank you!! 
Solved!
Go to Solution.
Attachments:
Match Strings.vi ‏8 KB
Match Strings.vi ‏8 KB

Here's another option (building on Jeff's code).  Turn on the Conditional Terminal on the FOR loop and change it to "Continue if TRUE".  This way, the loop will exit as soon as a failure is found.  Just pass the result straight out of the loop.  If none fail, then the FOR loop will exit on its own (from the auto-indexing) and a pass is passed out.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Attachments:
Match String.png ‏19 KB

Similar Messages

  • Match first word in a String

    I'm writing a program to reorganize some music. And I have a special case where bands that begin with 'The' need to be organized differently. So I'm writing a method to rename the music directories, but I am having trouble figuring out how to determine if the artist name begins with 'The'. Can someone point me in the right direction as to which java tool would help me in determining this case. The artist names are being passed in as Strings. TIA.
    Edited by: prem1ers on Dec 21, 2009 7:27 PM

    prem1ers wrote:
    Ok, thank you. I am not so comfortable with regex, so I will look for the easier way. Thanks again.Hint: if you are looking for "begins with", you're on the right track but not using quite the correct words to find the most suitable String method.

  • Match ANY word

    Is there a way to match ANY word in a string using CONTAINS?
    - e.g. Given a set of columns holding variations of text borrowed from above
    'you can optionally edit your post'
    'you can optionally preview your post'
    'you can optionally delete your post'
    and then match all 3 with something syntactically like
    and CONTAINS(<column>, 'optionally % your post') >0
    I predict using % is a bad idea as expansion will kill it as the index grows, but is there an alternative that will match a single word gap (so not using NEAR)?

    Although not intended for the purpose, using a stopword has the effect of requiring that it match any word. You could use an existing stopword like "the" or you could create your own stoplist and your own stopword for the purpose like "anyword", as demonstrated below. The stopword is not indexed, but its location is recorded, so a word must be present in that spot. I suspect it might be faster than % or NEAR or other methods.
    SCOTT@orcl_11gR2> CREATE TABLE test_tab
      2    (test_col  VARCHAR2(60))
      3  /
    Table created.
    SCOTT@orcl_11gR2> INSERT ALL
      2  INTO test_tab VALUES ('you can optionally edit your post')
      3  INTO test_tab VALUES ('you can optionally preview your post')
      4  INTO test_tab VALUES ('you can optionally delete your post')
      5  INTO test_tab VALUES ('some other data')
      6  SELECT * FROM DUAL
      7  /
    4 rows created.
    SCOTT@orcl_11gR2> BEGIN
      2    CTX_DDL.CREATE_STOPLIST ('test_stoplist', 'BASIC_STOPLIST');
      3    CTX_DDL.ADD_STOPWORD ('test_stoplist', 'ANYWORD');
      4  END;
      5  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11gR2> CREATE INDEX test_idx
      2  ON test_tab (test_col)
      3  INDEXTYPE IS CTXSYS.CONTEXT
      4  PARAMETERS ('STOPLIST test_stoplist')
      5  /
    Index created.
    SCOTT@orcl_11gR2> SELECT token_text FROM dr$test_idx$i
      2  /
    TOKEN_TEXT
    CAN
    DATA
    DELETE
    EDIT
    OPTIONALLY
    OTHER
    POST
    PREVIEW
    SOME
    YOU
    YOUR
    11 rows selected.
    SCOTT@orcl_11gR2> SELECT * FROM test_tab
      2  WHERE  CONTAINS (test_col, 'optionally ANYWORD your post') > 0
      3  /
    TEST_COL
    you can optionally edit your post
    you can optionally preview your post
    you can optionally delete your post
    3 rows selected.

  • How to search for words in a string?

    I have a list of strings that I need to search for instances
    of a certain word (or part of that word) is there a way of doing
    this in flash please?

    Quickest and easiest way to do it is to search through an
    array of manually entered words.

  • Delete the first word in a string?

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

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

  • Even more about deleting the first word in a string

    hi, i have this code that removes the first word in a string, returns the shorter string, removes the first word from the shorter string aso... what i would like it to do is to stop when it hits a non-character, but i can't get it to do that. does anyone know why \b won't work?
    import java.io.*;
    class Testar {
    public static void main(String[] args) {
          String partDesc = "Hi my name is SandraPandra.";
          while (partDesc.equals("\b") == false) {  //this is where something goes wrong
              System.out.println(partDesc);
              partDesc = partDesc.replaceFirst("^(\\w+)\\s+","");
    } thanx in advance!

      while (partDesc.equals("\b") == false) That compares partDesc to a string consisting of one backspace character. I suspect you're trying to use the regex word-boundary anchor, but that's a dead end. If you want to stop beheading the string when the regex stops matching, you can write the code exactly that way: class Testar {
      public static void main(String[] args) {
        String partDesc = "Hi my name is SandraPandra.";
        while ( partDesc.matches("^(\\w+)\\s+.*") ) {
          partDesc = partDesc.replaceFirst("^(\\w+)\\s+","");
          System.out.println(partDesc);
    } If performance is a concern, you can use a pre-compiled Pattern object for greater efficiency. Thanks to Matcher's lookingAt() method, you can use the same regex for the test and the replacement: class Testar {
      public static void main(String[] args) {
        String partDesc = "Hi my name is SandraPandra.";
        Pattern p = Pattern p = Pattern.compile("^(\\w+)\\s+");
        Matcher m = p.matcher(partDesc);
        while ( m.lookingAt() ) {
          partDesc = m.replaceFirst("");
          System.out.println(partDesc);
          m.reset(partDesc);
    } The ^ anchor isn't really necessary in this version, since lookingAt() implicitly anchors the match to the beginning of the string, but you might as well leave it in.

  • Can I sort a column based upon a "find" word?  i.e. I want to group all the rows that contain a certain word.  I'm using Numbers '09 on a Macbook Pro.  Thanks for your help!

    A second question: I am creating a database of products for my point of sale system.  I am using a product list sent to me by a vendor.  Can I pull out certain words in their description and add them to a new column.  i.e. The vendors' description in one cell is "Blueridge Guitar Dreadnought."  Can I automatically add the word "Dreadnought" to a new column in the same row?

    You can extract the word case where the string contains case using
    =IFERROR(IF(FIND("CASE",B)>0,"CASE",""),"")
    But that doesn't solve the issue of what goes in that column for lines where the product ins not a case.
    Looking at the other columns, I don't see a means of getting "Hardshell" from the given data using a formula.
    A semi-manual method using the "Show rows... feature of the Reorganize panel might prove efficient.
    Here, the Show rows... displayd was applied, then CASE was entered in the first cell in column A and filled down to the last visible cell. As can be seen below, the fill operation placed "CASE" in only the rows where column B containsed "CASE".
    Regards,
    Barry

  • Search for a word in a string.

    Hello everybody,
    Could anybody help me how to search for a word in a string ?
    Example: I have a string as below:
    String[] weather = {"snow", "rain", "sunny", "temperature", "storm", "freezing"};
    And I have a sentence like this:
    "Today is a sunny day"
    I want to break this sentence to pickup the word "sunny" and search this word in String[] weather to see if they match. How could i do that?
    Thank you very much. I really appreciate.
    still_learn

    1 iterate through the strings in your array.
    2. use String.indexOf(...) to test if the query string is present in the string

  • Regex - match a word except when it's preceeded by another word

    Does anyone know how to write a regular expression that will match an occurrence of a word except when it's preceeded by another word? I'm trying to match all occurrences of the word "function" except when it's part of the phrase "end function". Is that possible in a single regular expression?

    Maybe this is just how it works, but I'm not sure why a string
    with one space wouldn't match but a string with two would.At the beginning of the spaces, the lookbehind causes the match to fail, but then the Matcher bumps ahead one position and tries again. At that point, the lookbehind expression doesn't apply anymore, so you get a match. (You should be able to confirm this by counting the spaces in your output.) I tried using the "aggressive plus" to force it to treat all the spaces as one atom, but that didn't work:
      Pattern p = Pattern.compile("(?<!end)(\\s++)function");I don't see how to do this using "pure" lookaround, but if you don't mind matching the preceding word, this will work:
      Pattern p = Pattern.compile("(^|(?!end\\b)\\b\\w+ +)function\\b",
                                  Pattern.MULTILINE);Getting pretty hairy, I know, but it matches the word "function", either as the first thing on the line, or preceded by a word that is not "end" (those first couple of \b's are there to ensure that only the whole word "end" will block the match). Here's how you would use this pattern to replace "function" with "method", except when it's preceded by "end":
    import java.util.regex.*;
    public class Test
      public static void main(String[] args)
        String target = "end function\n"
                      + "function test\n"
                      + "functioning test\n"
                      + "test function\n"
                      + "test function end\n"
                      + "end    function\n"
                      + "ending function\n"
                      + "rend   function\n"
                      + "end   functioning\n";
        Pattern p = Pattern.compile("(^|(?!end\\b)\\b\\w+ +)function\\b",
                                    Pattern.MULTILINE);
        Matcher m = p.matcher(target);
        target = m.replaceAll("$1method");
        System.out.println(target);
    }Here's the output I get:
    end function
    method test
    functioning test
    test method
    test method end
    end    function
    ending method
    rend   method
    end   functioningOf course, if you do know that there will always be exactly one space between "end" and "function", none of this is necessary; you can just use dcostakos's original lookbehind regex--except that I would add word boundaries:
    Pattern p = Pattern.compile("(?<!end\\s)\\bfunction\\b");

  • How can I create a text pop up window in my Pages document? I want text to pop up when the reader hovers his/her cursor over a certain word.

    How can I create a text pop up window in my Pages document? I want text to pop up when the reader hovers his/her cursor over a certain word in the document. I am teacher. So for example when a student came to word he/she did not know, if he/she hovered the cursor over the word, a defintion or other information would appear.  You can do this in Word using bookmarks/hyperlinks but I can't figure this out in Pages. I can link it to another point in my Pages document but I just need the text to pop up - not take the reader to another location.  THANK YOU!!!!!!

    Have you tried Word for Mac?
    You will need to test if links survive export or printing to .pdf
    Peter

  • I just downloaded Pages. When typing on a blank document, I am unable to highlight certain words.  My daughter usesbitbfor homework and needs to highlight her spelling words.  I've read disucssions and it says gonto the a and enter fill and cg

    I just started using Pages and am trying to figure out how I can highlight certain words in sentences.  I have read some of the discussions and they have said to go to the "a" on the top bar.  When using a blank document, the letter "a" doesn't show up and there isn't an option to fill in or use shadowing.  Help!

    At the top of the screen in Page there is an "I" next to the Media Icon. If you tap that "I" icon - you bring up a menu that has Style as one of the options. Tap Style and you can change the color of the text and use all of the preinstalled Styles available in the app.
    If you swipe all the way to the bottom of the Styles menu- there is a Text Options listed. Tap on that and you can select different sizes, fonts, and text colors.

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

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

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

  • Getting one character at a certain position from a string array

    Hi, i'm new at learning java, but have strong experience at C++ and asm. How would i get one character at a certain positon from a string array.
    for example:
    String Phrases[] = {"To be or not to be, that is the question","The Simpsons","The Mole","Terminator three rise of the machines","The matrix"};
    that is my string array above.
    lets say i wanted to get the first character from the first element of the array which is "T", how would i get this

    ok well that didn't work, but i found getChars function can do what i want. One problem, how do i check the contents of char array defined as char Inchar[];

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

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

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

  • How to search for a particular word in a string?

    How to search for a particular word in a string?
    thanks for your help....

    This works fine.
    public class Foo {
        public static void main(String[] args) {
        String s = "Now is the time for all good...";
        String s2 = "the time";
        System.out.println(s.contains(s2));
        System.out.println(s.contains("for al"));
        System.out.println(s.contains("not here"));
    }output:true
    true
    falseYou must have something else wrong in your code.
    JJ

Maybe you are looking for

  • How do I transfers books from ADE to Sony Reader Library?

    Got new Sony e reader and want to transfer books from my Adobe Digital Editions library and cant get my Adobe Library to recognize my Sony Reader.   Have been live chatting with Adobe and Sony to no avail all day yesterday.   Hope someone out there c

  • TS1717 Windows 7: Blue Screens of Death because of iTunes

    My computer runs on Windows 7 and ever since I've installed iTunes, I have regurlarly Blues Screens, which only occur when iTunes is running. Any idea about how, why and potential fixes?

  • How to transfer downloaded apps to another computer?

    i've downloaded some free apps on my work computer through itunes. is there anyway i, copied them onto a usb thumb drive and put them on my home computer (as i don't have access to internet at home). How can i get them to show up on itunes to sync to

  • Trying to install final cut on my macbook pro. HELP!!!!!!

    hello i have a macbook pro. i am trying to install final cut. when i put the disc in and follow the prompts, it tells me that my computer no longer supports this power pc application. if i download os x mountain lion, will i be able to install final

  • Lightweight APs used with WLC

    After reading the Cisco documentation, it seems that the Lightweight AP's are reduced to ceiling/wall decorations when the WLC is off the network or otherwise unreachable.  Is this true?  Do they provide for no client connectivity whatsoever if the W