Function std.string.tr
Replaces the characters in which are in str with the
the corresponding characters in from and returns the resulting string.
to
is based on
Posix's trtr,
though it doesn't do everything that the Posix utility does.
Prototype
C1[] tr(C1, C2, C3, C4)( C1[] str, const(C2)[] from, const(C3)[] to, const(C4)[] modifiers = null );
Parameters
| Name | Description |
|---|---|
| str | The original string. |
| from | The characters to replace. |
| to | The characters to replace with. |
| modifiers | String containing modifiers. |
Modifiers
'c'from'd'to's' If the modifier 'd' is present, then the number of characters in
may be only to0 or 1.
If the modifier 'd' is not present, and is empty, then
to is taken toto be the same as .
from
If the modifier 'd' is not present, and is shorter than
to, then from is extended by replicating the last character in
to.
to
Both and from may contain ranges using the to'-' character
(e.g. "a-d" is synonymous with "abcd".) Neither accept a leading
'^' as meaning the complement of the string (use the 'c' modifier
for that).
Authors
Walter Bright, Andrei Alexandrescu, and Jonathan M Davis