static public Map < String , List < GroupInfo > > extractGroupInfo ( String namedPattern ) { Map < String , List < GroupInfo > > groupInfo = new LinkedHashMap < String , List < GroupInfo > > ( ) ; java . util . regex . Matcher matcher = NAMED_GROUP_PATTERN . matcher ( namedPattern ) ; while ( matcher . find ( ) ) { int pos = matcher . start ( ) ; // ignore escaped paren if ( isEscapedChar ( namedPattern , pos ) ) continue ; String name = matcher . group ( INDEX_GROUP_NAME ) ; int groupIndex = countOpenParens ( namedPattern , pos ) ; List < GroupInfo > list ; if ( groupInfo . containsKey ( name ) ) { list = groupInfo . get ( name ) ; } else { list = new ArrayList < GroupInfo > ( ) ; } list . add ( new GroupInfo ( groupIndex , pos ) ) ; groupInfo . put ( name , list ) ; } return groupInfo ; }
Parses info on named capture groups from a pattern