java.util.regex.PatternSyntaxException: Unclosed character class
Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character class near index 1 $[ ^ at java.util.regex.Pattern.error (Pattern.java:1503) at java.util.regex.Pattern.clazz(Pattern.java:2016) at java.util.regex.Pattern.sequence(Pattern.java:1560) at java.util.regex.Pattern.expr(Pattern.java:1520) at java.util.regex.Pattern.compile (Pattern.java:1288) at java.util.regex.Pattern.<init>(Pattern.java:1044) encountered while splitting the string using a delimiter which contains "["
January 24, 2010 | Filed Under Java
Related Post
Comments
One Response to “java.util.regex.PatternSyntaxException: Unclosed character class”
Leave a Reply
This error can be encountered while splitting a string or using string.replaceAll(”string which contains a special character”,”x”)
Following are the special characters in java regular expressions. If you have any one of them in your input string, then you will face this exception.
Use the common methodology of backslash to escape such characters.