Skip to main content
2 of 3
Matcher.matches link and description.
Phil W
  • 38.1k
  • 5
  • 53
  • 106

The issue is not Pattern.quote, but rather your use of Matcher.find:

Attempts to find the next subsequence of the input sequence that matches the pattern. This method returns true if a subsequence of the input sequence matches this Matcher object's pattern.

So Matcher.find skips non-matching data to find the next match.

Whole word matching requires you to use the word boundary matchers like \b, while whole input matching is achieved using Matcher.matches:

Attempts to match the entire region against the pattern.

Phil W
  • 38.1k
  • 5
  • 53
  • 106