An instance of the Matcher class performs various match operations on a character sequence by interpreting a compiled regular expression represented by an instance of Pattern. This is how we use this class to match a regex:
- We create a matcher instance from a pattern by invoking the pattern's matcher method that requires the input sequence as argument
- The instance of matcher is used to perform three types of match operations using these three methods, each returning a Boolean value (true indicates success):
These methods perform the matching in the following manner:
- The matches method attempts to match the complete input sequence using the matcher's pattern
- The find method searches the input ...