strippedLeft

Returns a slice of the passed string with any preceding whitespace and/or linebreaks sliced off. Overload that implicitly strips " \n\r\t".

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

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

Parameters

line string

Line to strip the left side of.

Return Value

Type: auto

The passed line without any preceding whitespace or linebreaks.

Examples

static if (!is(typeof("blah".strippedLeft) == string))
{
    enum message = "`lu.string.strippedLeft` should return a mutable string";
    static assert(0, message);
}

{
    immutable preceded = "   abc";
    immutable stripped = preceded.strippedLeft;
    assert((stripped == "abc"), stripped);
}
{
    immutable preceded = "   ";
    immutable stripped = preceded.strippedLeft;
    assert((stripped == ""), stripped);
}
{
    immutable empty = "";
    immutable stripped = empty.strippedLeft;
    assert((stripped == ""), stripped);
}
{
    immutable noPreceded = "abc";
    immutable stripped = noPreceded.strippedLeft;
    assert((stripped == noPreceded), stripped);
}
{
    immutable linebreak  = "\r\n\r\n  abc";
    immutable stripped = linebreak.strippedLeft;
    assert((stripped == "abc"), stripped);
}