Is there an algorithm somewhere in Phobos which performs when possible a replacement/substitution based on a variadic definition of replacements using hash-table search similar to

string replaceWhole(string a)
{
    switch (x)
    {
    case "a": return "1";
    case "b": return "2";
    default:  return x;
    }
}

?

Desired interface

y = x.replaceWhole!("a","x",
                    "b","y",
                    "c","z")

or perhaps

y = x.replaceWhole!(tuple("a","x"),
                    tuple("b","y"),
                    tuple("c","z"))


kind of like

"a".among!("a", "b", "c")

but for replacements.

Reply via email to