Menu

#4 Make the list of captured group names available

open
nobody
5
2004-05-26
2004-05-26
Anonymous
No

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));
}

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.