I have a regex with multiple disjunctive capture groups
(a)|(b)|(c)|...
Is there a faster way than this one to access the index of the first successfully matching capture group?
(matcher is an instance of java.util.regex.Matcher)
int getCaptureGroup(Matcher matcher){
    for(int i = 1; i <= matcher.groupCount(); ++i){
        if(matcher.group(i) != null){
            return i;
        }
    }
}
 
     
    