public String createReplacement(String template) {
    myTemplate = template;
    resetState();
    while (myCursor < myTemplate.length()) {
      char nextChar = myTemplate.charAt(myCursor++);
      if (nextChar == '\\') {
        processEscapedChar();
      } else if (nextChar == '$') {
        processGroupValue();
      } else {
        myReplacement.append(nextChar);
      }
    }
    return generateResult();
  }
public String createReplacement(String template)