private String replaceGroupsInMacroStep ( Matcher macroMatcher , String action ) { Matcher groupMatcher = groupPattern . matcher ( action ) ; while ( groupMatcher . find ( ) ) { String match = groupMatcher . group ( ) ; String groupString = match . substring ( 2 , match . length ( ) - 1 ) ; int groupId = Integer . parseInt ( groupString ) ; if ( groupId > macroMatcher . groupCount ( ) ) { throw new ChorusException ( "Capture group with index " + groupId + " in StepMacro step '" + action + "' did not have a matching capture group in the pattern '" + pattern . toString ( ) + "'" ) ; } String replacement = macroMatcher . group ( groupId ) ; replacement = RegexpUtils . escapeRegexReplacement ( replacement ) ; log . trace ( "Replacing group " + match + " with " + replacement + " in action " + action ) ; action = action . replaceFirst ( "<\\$" + groupId + ">" , replacement ) ; } return action ; }
capturing group from the macroMatcher