if (maxLoops < index) {
break;
}
for (int i = 0; i <= groupCount; i++) {
context.put("_"+i, new NodeVariable(matcher.group(i)));
}
BaseElementDef resultDef = regexpDef.getRegexpResultDef();
Variable result = getBodyTextContent(resultDef, scraper, context, true);
debug(resultDef, scraper, result);
String currResult = (result == null) ? matcher.group(0) : result.toString();
if (isReplace) {
matcher.appendReplacement(buffer, currResult);
} else {
resultList.add(new NodeVariable(currResult));
}
for (int i = 0; i <= groupCount; i++) {
context.remove("_"+i);
}
}
if (isReplace) {
matcher.appendTail(buffer);
resultList.add(new NodeVariable(buffer.toString()));
}
}
return new ListVariable(resultList);