private String restoreNBTTags(String str,ArrayList<String> nbttags){
  int nbtidx=1;
  for (  String capture : nbttags) {
    str=str.replace("NBT" + nbtidx++,capture);
  }
  return str;
}

private String restoreNBTTags ( String str , ArrayList < String > nbttags ) { int nbtidx = 1 ; for ( String capture : nbttags ) { str = str . replace ( "NBT" + nbtidx ++ , capture ) ; } return str ; }
and the reverse , restore the glorious nbt tags into a string loaded with their placeholders
