コード例 #1
0
 /**
  * Interprets the command-line argument as a regular expression
  * (supporting closure, binary or, parentheses, and wildcard)
  * reads in lines from standard input; writes to standard output
  * those lines that contain a substring matching the regular
  * expression.
  *
  * @param args the command-line arguments
  */
 public static void main(String[] args) { 
     String regexp = "(.*" + args[0] + ".*)";
     NFA nfa = new NFA(regexp);
     while (StdIn.hasNextLine()) { 
         String line = StdIn.readLine();
         if (nfa.recognizes(line)) {
             StdOut.println(line);
         }
     }
 } 
コード例 #2
0
ファイル: NFA.cs プロジェクト: franklzt/DataStruct
 /**
  * Unit tests the {@code NFA} data type.
  *
  * @param args the command-line arguments
  */
 public static void main(String[] args) {
     String regexp = "(" + args[0] + ")";
     String txt = args[1];
     NFA nfa = new NFA(regexp);
     StdOut.println(nfa.recognizes(txt));
 }