stripLeft

Strips leading whitespace (as defined by std.uni.isWhite) or as specified in the second argument.

  1. auto stripLeft(Range input)
  2. auto stripLeft(Range input, const(Char)[] chars)
    stripLeft
    (
    Range
    Char
    )
    (
    Range input
    ,
    const(Char)[] chars
    )

Parameters

input Range

string or forward range of characters

chars const(Char)[]

string of characters to be stripped

Return Value

Type: auto

input stripped of leading whitespace or characters specified in the second argument.

Postconditions: input and the returned value will share the same tail (see std.array.sameTail).

Examples

assert(stripLeft("     hello world     ", " ") ==
       "hello world     ");
assert(stripLeft("xxxxxhello world     ", "x") ==
       "hello world     ");
assert(stripLeft("xxxyy    hello world     ", "xy ") ==
       "hello world     ");
import std.array : array;
import std.utf : byChar, byWchar, byDchar;

assert(stripLeft("  xxxyy hello world     "w.byChar, "xy ").array ==
       "hello world     ");

assert(stripLeft("\u2028\u2020hello world\u2028"w.byWchar,
                 "\u2028").array == "\u2020hello world\u2028");
assert(stripLeft("\U00010001hello world"w.byWchar, " ").array ==
       "\U00010001hello world"w);
assert(stripLeft("\U00010001 xyhello world"d.byDchar,
                 "\U00010001 xy").array == "hello world"d);

assert(stripLeft("\u2020hello"w, "\u2020"w) == "hello"w);
assert(stripLeft("\U00010001hello"d, "\U00010001"d) == "hello"d);
assert(stripLeft(" hello ", "") == " hello ");

See Also

Generic stripping on ranges: std.algorithm.mutation._stripLeft

Meta