String Matching Example in Java String matches method in Java can be used to test String against regular
expression in Java. String matches() method is
one of the most convenient way of checking if String matches to a regular expression in Java or not. Quite often
we need to write code which needs to check if String
is numeric, Does String contains alphabets e.g. A to Z or a to Z, How to check
if String contains a particular digit 6 times etc. There are so many cases in
Java programming where we need regular expression. If you are familiar with
Java's regular expression API than you must know about java.util.regex.Pattern and java.util.regex.Matcher class,
these class provides regular expression capability to Java API. matches method
of String class actually delegate request to these classes. Anyway regular
expression can be best learn by seeing few examples and this is what we are
going to do in this Java String matches example
tutorial.