unEscape

Un-escapes characters in the input text.

unEscape
(
Range
)
(
Range range
,
const char[2][] pairs
)
if (
isInputRange!Range &&
isSomeChar!(ElementType!Range)
)
in { foreach (pair; pairs) { assert (pair[0] != '\\', "the backslash should not be set as pair"); assert (pair[1] != '\\', "the backslash should not be set as pair"); } }

Parameters

range
Type: Range

The character range to process. The source is not consumed.

pairs
Type: char[2][]

An array of pair. Each pair (char[2]) defines a target and a source character. The slash is automatically unescaped and must not be included in the array.

Return Value

Type: auto

An array of character whose type matches the range element type. Even if invalid, any unterminated sequence located at the end of the range is appended to the result.

Examples

1 assert( `1\"`.unEscape([['"','"']]) == `1"`);
2 assert(`1\"1\"11\"1`.unEscape([['"','"']]) == `1"1"11"1`);
3 assert(`\n\"1`.unEscape([['"','"'],['\n','n']]) == "\n\"1");
4 assert(`\\\\`.unEscape([]) == `\\`);
5 assert(`\\`.unEscape([]) == `\`);
6 assert(`\`.unEscape([]) == `\`);

Meta