1 57 58 import org.apache.oro.text.regex.*; 59 import org.apache.oro.text.perl.*; 60 61 68 public final class didNotMatch { 69 70 75 public static final void main(String args[]) { 76 String pattern, input; 77 Perl5Util perl; 78 79 if(args.length < 2) { 80 System.err.println("Usage: didNotMatch pattern input"); 81 System.exit(1); 82 } 83 84 pattern = args[0]; 85 input = args[1]; 86 perl = new Perl5Util(); 87 88 try { 91 if(perl.match(pattern, input)) { 92 System.out.println("Pre : " + perl.preMatch()); 93 System.out.println("Post: " + perl.postMatch()); 94 } else 95 System.err.println("There was no match."); 96 } catch(MalformedPerl5PatternException e) { 97 System.err.println("You entered an invalid pattern."); 98 System.err.println("Error: " + e.getMessage()); 99 System.exit(1); 100 } 101 102 } 103 104 } 105 | Popular Tags |