public static String replacePlaceholders(String source,String[] replacements){
  String result=source;
  int index=0;
  Pattern pattern=Pattern.compile("\\{\\}");
  while (true) {
    Matcher matcher=pattern.matcher(result);
    if (matcher.find()) {
      try {
        if (replacements.length > index) {
          result=result.replaceFirst(pattern.pattern(),StringEscapeUtils.escapeJava(replacements[index]));
        }
 else {
          result=result.replaceFirst(pattern.pattern(),"");
        }
      }
 catch (      Exception e) {
        result=result.replaceFirst(pattern.pattern(),"");
      }
      index++;
    }
 else {
      break;
    }
  }
  return StrgUtils.removeDuplicateWhitespace(result);
}

public static String replacePlaceholders ( String source , String [ ] replacements ) { String result = source ; int index = 0 ; Pattern pattern = Pattern . compile ( "\\{\\}" ) ; while ( true ) { Matcher matcher = pattern . matcher ( result ) ; if ( matcher . find ( ) ) { try { if ( replacements . length > index ) { result = result . replaceFirst ( pattern . pattern ( ) , StringEscapeUtils . escapeJava ( replacements [ index ] ) ) ; } else { result = result . replaceFirst ( pattern . pattern ( ) , "" ) ; } } catch ( Exception e ) { result = result . replaceFirst ( pattern . pattern ( ) , "" ) ; } index ++ ; } else { break ; } } return StrgUtils . removeDuplicateWhitespace ( result ) ; }
replaces a string with placeholder ( { } ) with the string from the replacement array the strings in the replacement array have to be in the same order as the placeholder in the source string
