strip

Array-specialization of strip with default predicate.

  1. inout(T)[] strip(inout(T)[] haystack, T needle)
    @trusted
    inout(T)[]
    strip
    (
    T
    )
    (
    scope return inout(T)[] haystack
    ,
    scope const T needle
    )
  2. inout(char)[] strip(inout(char)[] haystack)

Examples

assert("beta".strip(' ') == "beta");
assert(" beta ".strip(' ') == "beta");
assert("  beta  ".strip(' ') == "beta");
assert("   beta   ".strip(' ') == "beta");
assert(" _ beta _ ".strip(' ') == "_ beta _");
assert(" _  beta _ ".strip(' ') == "_  beta _");

char[] f()() @safe pure nothrow { char[1] x = "_"; return x[].strip(' '); }
static if (isDIP1000) static assert(!__traits(compiles, { auto _ = f(); }));
const ubyte[3] x = [0, 42, 0];
assert(x.strip(0) == x[1 .. 2]);

See Also

Meta