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.

3
  • MessageFormat should be what you are looking for Commented May 2, 2018 at 11:40
  • You may implement one yourself using a matcher. At each {\d} you may pause and append your replacement. Commented May 2, 2018 at 11:40
  • 1
    Check Java Equivalent to .NET's String.Format - MrSnowflake's answer. It is exactly what you are looking for. Commented May 2, 2018 at 11:41

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.