On Monday, 30 December 2019 at 06:47:37 UTC, Marcone wrote:
Use Python format() style:import std; import std: Format = format; // format() string format(T...)(T text){ string texto = text[0]; foreach(count, i; text[1..$]){ texto = texto.replaceFirst("{}", to!string(i));texto = texto.replace("{%s}".Format(to!string(count)), to!string(i));} return texto; }
This leaks too much. writeln("Helo {} {}".format("xx", "name")); // Helo xx name writeln("Helo {} {}".format("{}", "name")); // Helo name {}