What\'s the difference between String.matches and Matcher.matches? Is there any difference in terms of performance or other things?
String.matches
internally calls Pattern.matches(regex, str)
.
The problem with it is that each time you call it you recompile the pattern, which cost some resources.
It is better to compile your pattern once, then try to match it against all the Strings you want. I personally use a Patterns class containing all my pattern in my app declared as final and static