code: public String replace(CharSequence input, VariableResolver resolver){
          StringBuilder buff = new StringBuilder();
  
          Matcher matcher = pattern.matcher(input);
          int cursor = 0;
          while(cursor<input.length() && matcher.find(cursor)){
              buff.append(input.subSequence(cursor, matcher.start()));
              String value = resolver.resolve(matcher.group(1));
              buff.append(value!=null ? value : matcher.group());
              cursor = matcher.end();
          }
          buff.append(input.subSequence(cursor, input.length()));
          return buff.toString();
      }
docs: /*-------------------------------------------------[ Replace ]---------------------------------------------------