0

I need to augment some string like it's done by logback/famous loggers or property accessors.

String str= "I can {0} give {1} back your horses or restore your {2} to life.";
String[] got=new String[]{"not","you","dead"};

Are they any utility functions provided by any library that can convert str to replace {i} with indices in array?

Its most probably a duplicate and please refer me to some similar question.

Sachin Verma
  • 3,712
  • 10
  • 41
  • 74
  • `MessageFormat` should be what you are looking for – AxelH May 02 '18 at 11:40
  • You may implement one yourself using a matcher. At each `{\d}` you may pause and append your replacement. – Tim Biegeleisen May 02 '18 at 11:40
  • 1
    Check [Java Equivalent to .NET's String.Format - MrSnowflake's answer](https://stackoverflow.com/a/10977910/4391450). It is exactly what you are looking for. – AxelH May 02 '18 at 11:41

0 Answers0