The string methods in Java that use the regular expressions need to escape some special characters like [, (, *, $, +, \, . and so on. For example, lets consider the split() method. The following expressions will cause the run time exception java.util.regex.PatternSyntaxException.
String str="Java[language";
String arr[]=str.split("[");
String str="Java(language";
String arr[]=str.split("(");
String str="Java*language";
String arr[]=str.split("*");
String str="Java$language";
String arr[]=str.split("$");
String str="Java+language";
String arr[]=str.split("+");
All the above expressions cause the exception java.util.regex.PatternSyntaxException obviously because we need them to escape something like this String arr[]=str.split("\\[");. That’s quite obvious.
In case of dot ".", however the compiler silently parses it means that the expression String arr[]=str.split("."); causes no error, no warning or no exception at all even though its also the part of regular expressions and needs to be escaped. Why? (The string held by str will not be split in this case as obvious).
"."is a completely valid regular expression that matches any single character.