private void initPattern(){
  StringBuffer patternTemplateRegex=new StringBuffer();
  logger.debug("Get placeholder matcher");
  Matcher placeholderMatcher=getPlaceholderMatcher();
  logger.debug("Replace all placeholder with regex group capture");
  while (placeholderMatcher.find()) {
    String group=placeholderMatcher.group(1);
    if (!groups.contains(group)) {
      logger.trace("New group found, add it, replace with a capture group");
      groups.add(group);
      String groupRegex=getGroupRegex(group);
      placeholderMatcher.appendReplacement(patternTemplateRegex,Matcher.quoteReplacement("(?<" + group + ">"+ groupRegex+ ")"));
    }
 else {
      logger.trace("Existing group found, replace with a back reference");
      placeholderMatcher.appendReplacement(patternTemplateRegex,Matcher.quoteReplacement("\\k<" + group + ">"));
    }
  }
  placeholderMatcher.appendTail(patternTemplateRegex);
  String patternRegex=patternTemplateRegex.toString();
  logger.debug("pattern:" + patternRegex);
  pattern=Pattern.compile(patternRegex);
}

private void initPattern ( ) { StringBuffer patternTemplateRegex = new StringBuffer ( ) ; logger . debug ( "Get placeholder matcher" ) ; Matcher placeholderMatcher = getPlaceholderMatcher ( ) ; logger . debug ( "Replace all placeholder with regex group capture" ) ; while ( placeholderMatcher . find ( ) ) { String group = placeholderMatcher . group ( 1 ) ; if ( ! groups . contains ( group ) ) { logger . trace ( "New group found, add it, replace with a capture group" ) ; groups . add ( group ) ; String groupRegex = getGroupRegex ( group ) ; placeholderMatcher . appendReplacement ( patternTemplateRegex , Matcher . quoteReplacement ( "(?<" + group + ">" + groupRegex + ")" ) ) ; } else { logger . trace ( "Existing group found, replace with a back reference" ) ; placeholderMatcher . appendReplacement ( patternTemplateRegex , Matcher . quoteReplacement ( "\\k<" + group + ">" ) ) ; } } placeholderMatcher . appendTail ( patternTemplateRegex ) ; String patternRegex = patternTemplateRegex . toString ( ) ; logger . debug ( "pattern:" + patternRegex ) ; pattern = Pattern . compile ( patternRegex ) ; }
initialize the pattern to match files .
