code: static Matcher mergeNext(Matcher matcher) {
      if (matcher instanceof SeqMatcher) {
        List<Matcher> matchers = matcher.<SeqMatcher>as().matchers();
        List<Matcher> ms = new ArrayList<>();
        for (int i = 0; i < matchers.size(); ++i) {
          Matcher m = matchers.get(i);
          if (m instanceof GreedyMatcher) {
            List<Matcher> after = matchers.subList(i + 1, matchers.size());
            ms.add(m.<GreedyMatcher>as().mergeNext(SeqMatcher.create(after)));
            break;
          } else {
            ms.add(m);
          }
        }
        return SeqMatcher.create(ms);
      }
      return matcher;
    }
docs: For greedy matchers go ahead and include the next portion of the match so it can be
  checked as we go along. Since there is no support for capturing the value we can stop
  as soon as it is detected there would be a match rather than finding the largest possible
  match.