The original string.
The AA indicating which characters to replace and what to replace them with.
The characters to remove from the string.
An output range to write the contents to.
import std.array : appender; dchar[dchar] transTable1 = ['e' : '5', 'o' : '7', '5': 'q']; auto buffer = appender!(dchar[])(); translate("hello world", transTable1, null, buffer); assert(buffer.data == "h5ll7 w7rld"); buffer.clear(); translate("hello world", transTable1, "low", buffer); assert(buffer.data == "h5 rd"); buffer.clear(); string[dchar] transTable2 = ['e' : "5", 'o' : "orange"]; translate("hello world", transTable2, null, buffer); assert(buffer.data == "h5llorange worangerld");
This is an overload of translate which takes an existing buffer to write the contents to.