So I ran into a bug caused by expecting the matches() method to find exactly the same match as using find(). Normally this is the case, but it appears that if a non-greedy p
They are supposed to be different. Matcher#matches attempts to match the complete input string using the implicit anchors ^ and $ around your regex, whereas Matcher#find matches whatever your regex can match.
As per Javadoc:
public boolean matches()
Attempts to match the entire region against the pattern. If the match succeeds then more information can be obtained via the start, end, and group methods.
and
public boolean find()
Attempts to find the next subsequence of the input sequence that matches the pattern.