String containing {key} placeholders
Object whose keys are placeholder names and whose values are the replacements
The formatted string
An unknown key (food) is left as its own text rather than raising.
formatReplacementString(
'Hi, this is {name}! I like \\{curly braces\\}. I have a {carColor} car. Food: {food}.',
{ name: 'Bill', carColor: 'blue' },
);
// 'Hi, this is Bill! I like {curly braces}. I have a blue car. Food: food.'
Replaces each
{key}instrwithreplacers[key], coerces every part to a string, and joins them. An unknown key is replaced by the key text itself, and empty braces{}drop out leaving the surrounding text. See formatReplacementStringToArray to keep non-string replacers intact — a React element coerced through this function becomes[object Object].