findLastSkip

  1. auto findLastSkip(inout(T)[] haystack, T[] needle)
  2. auto findLastSkip(inout(T)[] haystack, T needle)
    @trusted
    findLastSkip
    (
    T
    )
    (
    scope ref inout(T)[] haystack
    ,
    scope const T needle
    )
  3. bool startsWith(T[] haystack, T[] needle)
  4. bool startsWith(T[] haystack, T needle)

Examples

const auto x = "abacc";
{
    string y = x;
    const bool ok = y.findLastSkip("_");
    assert(!ok);
    assert(y is x);
}
{
    string y = x;
    const bool ok = y.findLastSkip("a");
    assert(ok);
    assert(y == x[3 .. $]);
}
{
    string y = x;
    const bool ok = y.findLastSkip("c");
    assert(ok);
    assert(y is x[$ .. $]);
}
auto f()() @safe pure nothrow { char[1] x = "_"; return x[].findLastSkip(" "); }
static if (isDIP1000) static assert(!__traits(compiles, { auto _ = f(); }));
const auto x = "abacc";
{
    string y = x;
    const bool ok = y.findLastSkip('_');
    assert(!ok);
    assert(y is x);
}
{
    string y = x;
    const bool ok = y.findLastSkip('a');
    assert(ok);
    assert(y == x[3 .. $]);
}
{
    string y = x;
    const bool ok = y.findLastSkip('c');
    assert(ok);
    assert(y is x[$ .. $]);
}
auto f()() @safe pure nothrow { char[1] x = "_"; return x[].findLastSkip(' '); }
static if (isDIP1000) static assert(!__traits(compiles, { auto _ = f(); }));

Meta