stripLeft

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

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

Parameters

input Range

string or forward range of characters

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

import std.uni : lineSep, paraSep;
assert(stripLeft("     hello world     ") ==
       "hello world     ");
assert(stripLeft("\n\t\v\rhello world\n\t\v\r") ==
       "hello world\n\t\v\r");
assert(stripLeft(" \u2028hello world") ==
       "hello world");
assert(stripLeft("hello world") ==
       "hello world");
assert(stripLeft([lineSep] ~ "hello world" ~ lineSep) ==
       "hello world" ~ [lineSep]);
assert(stripLeft([paraSep] ~ "hello world" ~ paraSep) ==
       "hello world" ~ [paraSep]);

import std.array : array;
import std.utf : byChar;
assert(stripLeft("     hello world     "w.byChar).array ==
       "hello world     ");
assert(stripLeft("     \u2022hello world     ".byChar).array ==
       "\u2022hello world     ");

See Also

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

Meta