Skip to content

Instantly share code, notes, and snippets.

@jonas-grgt
Last active August 29, 2015 14:21
Show Gist options
  • Save jonas-grgt/be6023b63234f89029ce to your computer and use it in GitHub Desktop.
Save jonas-grgt/be6023b63234f89029ce to your computer and use it in GitHub Desktop.
Extract Regexp named group candidates
public static Set<String> getNamedGroupCandidates(String regex) {
Set<String> namedGroups = new TreeSet<>();
Matcher m = Pattern.compile("\\(\\?<([a-zA-Z0-9]*)>").matcher(regex);
while (m.find()) {
namedGroups.add(m.group(1));
}
return namedGroups;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment