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

Method - boolean matches(String regex)

This method attempts to match a given regular expression against the complete subject String and returns true/false, indicating whether the match is successful or not. The following are a few important points to note:

  • Regular expression is applied against the entire String; there is no partial matching
  • Regular expression does not need to be anchored using ^ and $, since it is matched against the entire input
  • The equivalent of Pattern.matches(String regex, CharSequenceinput) method (will be covered later)

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