stripLeft

Array-specialization of stripLeft with default predicate.

  1. inout(T)[] stripLeft(inout(T)[] haystack, T needle)
  2. inout(char)[] stripLeft(inout(char)[] haystack)
    pure nothrow @safe @nogc
    inout(char)[]
    stripLeft
    ()
    (
    scope return inout(char)[] haystack
    )
  3. bool startsWith(T[] haystack, T[] needle)
  4. bool startsWith(T[] haystack, T needle)

Examples

assert("beta".stripLeft(' ') == "beta");
assert(" beta".stripLeft(' ') == "beta");
assert("  beta".stripLeft(' ') == "beta");
assert("   beta".stripLeft(' ') == "beta");
assert("   beta".stripLeft() == "beta");
assert(" _ beta _ ".stripLeft(' ') == "_ beta _ ");
assert(" _  beta _ ".stripLeft(' ') == "_  beta _ ");
version (unittest) {
	static char[] f()() @safe pure nothrow { char[1] x = "_"; return x[].stripLeft(' '); }
	static if (hasPreviewDIP1000) static assert(!__traits(compiles, { auto _ = f(); }));
}

See Also

Meta