strippedLeft

Returns a slice of the passed string with any preceding passed characters sliced off. Implementation capable of handling both individual characters and strings of tokens to strip.

Duplicates std.string.stripLeft, which we can no longer trust not to assert on unexpected input.

  1. auto strippedLeft(string line)
  2. auto strippedLeft(Line line, Chaff chaff)
    @safe pure nothrow @nogc
    strippedLeft
    (
    Line
    Chaff
    )
    (
    return scope Line line
    ,
    const scope Chaff chaff
    )

Parameters

line Line

Line to strip the left side of.

chaff Chaff

Character or string of characters to strip away.

Return Value

Type: auto

The passed line without any preceding passed characters.

Examples

{
    immutable trailing = ",abc";
    immutable stripped = trailing.strippedLeft(',');
    assert((stripped == "abc"), stripped);
}
{
    immutable trailing = "!!!abc";
    immutable stripped = trailing.strippedLeft('!');
    assert((stripped == "abc"), stripped);
}
{
    immutable trailing = "abc";
    immutable stripped = trailing.strippedLeft(' ');
    assert((stripped == "abc"), stripped);
}
{
    immutable trailing = "";
    immutable stripped = trailing.strippedLeft(' ');
    assert(!stripped.length, stripped);
}
{
    immutable trailing = ",abc";
    immutable stripped = trailing.strippedLeft(",");
    assert((stripped == "abc"), stripped);
}
{
    immutable trailing = "!!!abc";
    immutable stripped = trailing.strippedLeft(",1!");
    assert((stripped == "abc"), stripped);
}
{
    immutable trailing = "abc";
    immutable stripped = trailing.strippedLeft(" ");
    assert((stripped == "abc"), stripped);
}
{
    immutable trailing = "";
    immutable stripped = trailing.strippedLeft(" ");
    assert(!stripped.length, stripped);
}

Meta