public Value matchPositions(Value str) { PatternMatcher matcher = getMatcher(); // Do the matching PatternMatcherInput jStr = new PatternMatcherInput(string(str)); Pair result = null; Pair prev = null; boolean found = false; while (matcher.contains(jStr, pattern)) { found = true; MatchResult matchResult = matcher.getMatch(); for (int i = 0, length = matchResult.groups(); i < length; i++) { Pair m = new Pair( Quantity.valueOf(matchResult.beginOffset(i)), Quantity.valueOf(matchResult.endOffset(i))); Pair elem = new Pair(m, EMPTYLIST); if (result == null) result = prev = elem; else { prev.setCdr(elem); prev = elem; } } } if (!found) return FALSE; else return result; }
public Value match(Value str) { PatternMatcher matcher = getMatcher(); // Do the matching PatternMatcherInput jStr = new PatternMatcherInput(string(str)); Pair result = null; Pair prev = null; boolean found = false; while (matcher.contains(jStr, pattern)) { found = true; MatchResult matchResult = matcher.getMatch(); for (int i = 0, length = matchResult.groups(); i < length; i++) { Pair m = new Pair(new SchemeString(matchResult.group(i)), EMPTYLIST); if (result == null) result = prev = m; else { prev.setCdr(m); prev = m; } } } if (!found) return FALSE; else return result; }