To match all the strings with .in the name, follow these steps:
Pattern.compile(".*[.].*");
To break it:
.* matches any number of arbitrary characters[.]corresponds to a point. (yes, \\.works too).* matches any number of arbitrary characters
Demo:
Pattern p = Pattern.compile(".*[.].*");
System.out.println(p.matcher("hello.txt").matches());
System.out.println(p.matcher("hellotxt").matches());
Note that a single dot line "."also matches. To make sure that you have some characters in front and after a point, you can change *to +: .+[.].+.
The reason you get PatternSyntaxException:
* " , ". *, , .