Make the list of captured group names available
Brought to you by:
samokhodkin
Add a method to matcher that returns a list of named
groups that were captured. You can provide a immutable
accessor (with a copy) to the keys in the map of
captured groups. Optionally, if you are keeping
unnamed groups there too, you can return their order
number as the key (same as \1 backreference).
Example:
matcher.find();
Collection groupNameColl = matcher.getGroupNames();
Iterator it = groupNameColl.iterator();
while (it.hasNext()) {
String groupName = (String) it.next();
logger.debug(matcher.getGroup(groupName));
}