static boolean matchEnd(S pat, S s) { return matchEnd(pat, s, null); } // matches are as you expect, plus an extra item for the rest string static boolean matchEnd(S pat, S s, Matches matches) { if (s == null) false; L tokpat = parse3(pat), toks = parse3(s); if (toks.size() < tokpat.size()) false; S[] m = match2(tokpat, takeLast(l(tokpat), toks)); if (m == null) false; if (matches != null) { matches.m = new S[m.length+1]; arraycopy(m, matches.m); matches.m[m.length] = join(dropLast(l(tokpat), toks)); // for Matches.rest() } true; }