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.