java - Regular expression for validating an answer to a question -


Hey everyone, I'm having a little difficulty in establishing a regular expression, which is used by a user in a text box Evaluates the recorded sentence; For keyword (s), the keyword is to be entered continuously from the other and both can have any number of first letters or vacancies, and after that (i.e. The keywords "crow" and "feet" are, crows somewhere Keeping this in view, this statement should be valid "Blah blah sakki kr dsjaft"). The letter and to a lesser extent, the spaces (I would like keywords with at least one space buffer at the beginning and end) are completely optional, the main concern is whether the keywords are entered in their proper order.

So far, I was able to work my regular expression in one sentence, but if the answer itself was recorded itself, then failed to work.

I have a regular expression in the function given below:

  // The Boolean Check Ancer (String A, String S) protected against the answer with the correct solution { Boolean result = false; // solution that is used to determine more than one word string temporary [] = s.split (""); // if only one word or letter (temp.length == 1) {if (s.length () == 1) {// Check multiple option questions if (a.equalsIgnoreCase (s)) result = true; And result = false; } Else {// If you want to answer fewer questions ((a.toLowerCase ()) matches. (". *? \\ *? S" + s.toLowerCase () + "\\ s *? . *? ")) Result = true; And result = false; }} And {int count = temp.length; // string regex = ". * *? \\ s *?" Regular expression used for; For (int i = 0; i   

Any help would be greatly appreciated thanks.

I have to go through this in a different way. Instead of trying to use a regular expression, why not use something similar:

  string reply = ... // Get the user's answer if answer (answer.indexOf ("Crow") & lt; answer.indexOf ("feet")} {// "right" answer}   

You still need to target words in the right answer, Then to see if a loop is checked in each indicator of each word is less than the index of the following words.

Comments