public void processMatchingSubstring(XPathContext context, OnGroup action) throws XPathException {
Receiver out = context.getReceiver();
int c = matcher.getParenCount()-1;
if (c == 0) {
out.characters(current.toString());
} else {
// Create a map from positions in the string to lists of actions.
// The "actions" in each list are: +N: start group N; -N: end group N.
IntHashMap<List<Integer>> actions = new IntHashMap<List<Integer>>(c);
for (int i=1; i<=c; i++) {