On Sunday, 16 April 2017 at 09:46:13 UTC, ag0aep6g wrote:
On 04/16/2017 11:20 AM, Joel wrote:[...]void main() { // Arrangeconst string templateString = "My {pet} has {number} {ailment}.";auto pairs = [ "pet": "dog", "number": "5", "ailment": "fleas", ]; // Act import std.regex: regex, replaceAll; auto result = templateString .replaceAll!(m => pairs[m[1]])(regex(`\{([^}]+)\}`)); // Assert assert(result == "My dog has 5 fleas."); }
Thanks, ag0aep6g.