stripped

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

It merely calls both strippedLeft and strippedRight. As such it duplicates std.string.strip, which we can no longer trust not to assert on unexpected input.

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

Parameters

line string

Line to strip both the right and left side of.

Return Value

Type: auto

The passed line, stripped of surrounding whitespace.

Examples

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

{
    immutable line = "   abc   ";
    immutable stripped_ = line.stripped;
    assert((stripped_ == "abc"), stripped_);
}
{
    immutable line = "   ";
    immutable stripped_ = line.stripped;
    assert((stripped_ == ""), stripped_);
}
{
    immutable line = "";
    immutable stripped_ = line.stripped;
    assert((stripped_ == ""), stripped_);
}
{
    immutable line = "abc";
    immutable stripped_ = line.stripped;
    assert((stripped_ == "abc"), stripped_);
}
{
    immutable line = " \r\n  abc\r\n\r\n";
    immutable stripped_ = line.stripped;
    assert((stripped_ == "abc"), stripped_);
}

Meta