} else {
props.put(name + i, sub[i]);
}
}
} else if (!single) {
Regsub rs = new Regsub(exp, data);
while(rs.nextMatch()) {
matches++;
matchList.append(" " + matches);
if (names != null) {
if (!names[0].equals("X")) {
props.put(name + matches + "." + names[0],
rs.matched());
}
} else {
props.put(name + matches, rs.matched());
}
// use sub-match as an index instead of a number
String otherKey = null;
if (subIndex > 0 && subIndex < subMatches) {
otherKey = rs.submatch(subIndex);
}
if (otherKey == null) {
otherKey = "" + matches;
}
for (int i = 1; i < subMatches; i++) {
String key;
if (names != null && names.length > i) {
if (names[i].equals("X")) {
continue;
}
key = name + otherKey + "." + names[i];
} else {
key = name + otherKey + "." + i;
}
props.put(key,
(rs.submatch(i)==null ? nullStr : rs.submatch(i)));
}
}
}
ok = (matches > 0);
props.put(name + "matches", matchList.toString());