Guest User

Untitled

a guest
Jan 10th, 2011
89
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $cat TestRegex.java
  2.  
  3.     import java.util.regex.*;
  4.     class TestRegex {
  5.        public static void main( String ... args ) {
  6.            System.out.printf("%s ~= %s ? %s  %n" , args[0].replaceAll("\\","\\\\"), args[1], Pattern.matches( args[0], args[1] ) );
  7.        }
  8.     }
  9.  
  10.  
  11. $javac TestRegex.java  
  12. $java TestRegex "\d+" "1"
  13. Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
  14. \
  15.  ^
  16.     at java.util.regex.Pattern.error(Pattern.java:1713)
  17.     at java.util.regex.Pattern.compile(Pattern.java:1466)
  18.     at java.util.regex.Pattern.<init>(Pattern.java:1133)
  19.     at java.util.regex.Pattern.compile(Pattern.java:823)
  20.     at java.lang.String.replaceAll(String.java:2189)
  21.     at TestRegex.main(TestRegex.java:5)
RAW Paste Data