if (alwaysEmpty) { REMatch result = matchRest(input, newMatch); if (result != null) { mymatch.assignFrom(result);
boolean stopMatchingIfSatisfied = (mymatch.matchFlags & REMatch.MF_FIND_ALL) == 0;  REMatch newMatch = matchMinimum(input, mymatch); if (newMatch == null) return false;   int[] visited = initVisited(); for (REMatch m = newMatch; m != null; m = m.next) { visited = addVisited(m.index, visited); }  int max1 = decreaseMax(max, min);  newMatch = _match(input, newMatch, max1, stopMatchingIfSatisfied, visited); if (newMatch != null) { mymatch.assignFrom(newMatch);
    boolean match(CharIndexed input, REMatch mymatch) {	// Possible positions for the next repeat to match at	REMatch newMatch = mymatch;	// {0} needs some special treatment.	if (alwaysEmpty) {		REMatch result = matchRest(input, newMatch);		if (result != null) {		    mymatch.assignFrom(result);		    return true;		}		else {	        return false;		}	    }	// number of times we've matched so far	int numRepeats = 0; 	REMatch doables;	int lastIndex = mymatch.index;	boolean emptyMatchFound = false;	while (numRepeats < min) {	    doables = findDoables(token, input, newMatch);	    // if none of the possibilities worked out, 	    // it means that minimum number of repeats could not be found.	    if (doables == null) return false;	    	    // reassign where the next repeat can match	    newMatch = doables;	    	    // increment how many repeats we've successfully found	    ++numRepeats;	    	    if (newMatch.empty) {		numRepeats = min;		emptyMatchFound = true;		break;	    }	    lastIndex = newMatch.index;	}	Vector positions = new Vector();	while (numRepeats <= max) {	    // We want to check something like  	    //    if (stingy)	    // and neglect the further matching.  But experience tells	    // such neglection may cause incomplete matching.	    // For example, if we neglect the seemingly unnecessay	    // matching, /^(b+?|a){1,2}?c/ cannot match "bbc".	    // On the other hand, if we do not stop the unnecessary	    // matching, /(([a-c])b*?\2)*/ matches "ababbbcbc"	    // entirely when we wan to find only "ababb".	    // In order to make regression tests pass, we do as we did.	    if (stopMatchingIfSatisfied && stingy) {		REMatch results = matchRest(input, newMatch);		if (results != null) {		    mymatch.assignFrom(results);		    return true;		}	    }	    positions.add(newMatch);	    if (emptyMatchFound) break;	    doables = findDoables(token, input, newMatch);	    if (doables == null) break;	    // doables.index == lastIndex occurs either	    //   (1) when an empty string was the longest	    //       that matched this token.	    // or	    //   (2) when the same string matches this token many times.	    //       For example, "acbab" itself matches "a.*b" and	    //       its substrings "acb" and "ab" also match.	    //       In this case, we do not have to go further until	    //       numRepeats == max because the more numRepeats grows,	    //       the shorter the substring matching this token becomes.	    //       So the previous succesful match must have bee the best	    //       match.  But this is not necessarily the case if stingy.	    if (doables.index == lastIndex) {	        if (doables.empty) {		    emptyMatchFound = true;		}	        else {		    if (!stingy) break;		    }		}	    numRepeats++;	    newMatch = doables;	    lastIndex = newMatch.index;	    }				// We're greedy, but ease off until a true match is found.	// At this point we've either got too many or just the right amount.	// See if this numRepeats works with the rest of the regexp.	REMatch.REMatchList allResults = new REMatch.REMatchList();	int posCount = positions.size();	int posIndex = (stingy ? 0 : posCount - 1);	while (posCount-- > 0) {	    REMatch m = (REMatch) positions.elementAt(posIndex);            if (stingy) posIndex++; else posIndex--;	    REMatch results = matchRest(input, m);	    if (results != null) {		    // Order these from longest to shortest		    // Start by assuming longest (more repeats)		// If stingy the order is shortest to longest.		allResults.addTail(results);		}	    else {	    if (possessive) break;	}	}	if (allResults.head != null) {	    mymatch.assignFrom(allResults.head); // does this get all?	    return true;	}	// If we fall out, no matches.	return false;    }