translate

This is an ASCII-only overload of translate which takes an existing buffer to write the contents to.

Parameters

str const(char)[]

The original string.

transTable const(char)[]

The string indicating which characters to replace and what to replace them with. It is generated by makeTransTable.

toRemove const(char)[]

The characters to remove from the string.

buffer Buffer

An output range to write the contents to.

Examples

import std.array : appender;
auto buffer = appender!(char[])();
auto transTable1 = makeTransTable("eo5", "57q");
translate("hello world", transTable1, null, buffer);
assert(buffer.data == "h5ll7 w7rld");

buffer.clear();
translate("hello world", transTable1, "low", buffer);
assert(buffer.data == "h5 rd");

Meta