@Override
    double matchAt(int i) {
        double bestResult = Double.POSITIVE_INFINITY;
        Regex.GroupMap tempGroups = null;
        Regex.GroupMap oldGroups = new Regex.GroupMap(owner.groups);
        int bestNum = -1;
        
        matchStart = i;
        matchLen = 0;
        
        for (int j = 0; j < children.length; j++) {
            double cur;
            owner.groups = new Regex.GroupMap(oldGroups);
            cur = children[j].matchAt(i); 
            if (cur < bestResult || cur == bestResult && children[j].getMatchLen() > matchLen) {
                bestNum = j;
                bestResult = cur;
                matchLen = children[j].getMatchLen();
                tempGroups = owner.groups;
            } // if
        } // for

        if (tempGroups != null) {
            owner.groups = tempGroups;
        } // if
        
        matchReplacement = (bestNum >= 0) ? children[bestNum].getReplacement() : null;
        saveGroup();
        
        return bestResult;
    } // matchAt