java pattern.matcher() vs pattern.matches()

pattern.matcher(String s) returns a Matcher that can find patterns in the String s

pattern.matches(String str) tests, if the entire String (str) matches the pattern.

In brief (just to remember the difference):

  • pattern.matcher - test if the string contains a pattern
  • pattern.matches - test if the string is a pattern

你可能感兴趣的:(java)