O'Reilly logo

Java 9 Regular Expressions by Anubhava Srivastava

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Matcher class

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):
    • matches
    • find
    • lookingAt

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required