1 Reply Latest reply: Nov 27, 2012 6:44 AM by rukbat RSS

    Regex clarification

      Hi ,

      How can i write a regex that matches the word Time/Mandatory/Request in same order.Is the below approach correct.
      public class Test {
           public static void main(String[] args) {
           String text ="1A Type: Air code H&C Text: [Time Mandatory If Time Window Requested]";
           //Trying to match tha pattern for the text in the same order.
           //String pattern1="[Time]|[Mandatory]|[Requested] ";
      //     String pattern1="^.*Time.*$";//(?=.*?\bMandatory\b)(?=.*?\bRequested\b).*$";
           String pattern1="^(?=.*?\bTime\b).*$" ;
           Pattern p = Pattern.compile(pattern1);
           Matcher m = p.matcher(text);
           while (m.find()) {
        • 1. Re: Regex clarification
          You already have an inquiry on this topic from a few short weeks ago:

          You seem to have abandoned that forum thread. You need to return to it and continue your discussion there. That will keep all your information in the same thread.

          This post is now locked.