stripSuffix

Strips the supplied string from the end of a string.

@safe pure nothrow @nogc
stripSuffix
(
return scope string line
,
const scope string suffix
)

Parameters

line string

Original line to strip the suffix from.

suffix string

Suffix string to strip.

Return Value

Type: auto

line with suffix sliced off the end.

Examples

string suffixed = "Kameloso";
string stripped = suffixed.stripSuffix("oso");
assert((stripped == "Kamel"), stripped);
immutable line = "harblsnarbl";
assert(line.stripSuffix("snarbl") == "harbl");
assert(line.stripSuffix("") == "harblsnarbl");
assert(line.stripSuffix("INVALID") == "harblsnarbl");
assert(!line.stripSuffix("harblsnarbl").length);