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
    )

Examples

1 const auto x = "abacc";
2 {
3     string y = x;
4     const bool ok = y.findLastSkip("_");
5     assert(!ok);
6     assert(y is x);
7 }
8 {
9     string y = x;
10     const bool ok = y.findLastSkip("a");
11     assert(ok);
12     assert(y == x[3 .. $]);
13 }
14 {
15     string y = x;
16     const bool ok = y.findLastSkip("c");
17     assert(ok);
18     assert(y is x[$ .. $]);
19 }
20 auto f()() @safe pure nothrow { char[1] x = "_"; return x[].findLastSkip(" "); }
21 static if (isDIP1000) static assert(!__traits(compiles, { auto _ = f(); }));
1 const auto x = "abacc";
2 {
3     string y = x;
4     const bool ok = y.findLastSkip('_');
5     assert(!ok);
6     assert(y is x);
7 }
8 {
9     string y = x;
10     const bool ok = y.findLastSkip('a');
11     assert(ok);
12     assert(y == x[3 .. $]);
13 }
14 {
15     string y = x;
16     const bool ok = y.findLastSkip('c');
17     assert(ok);
18     assert(y is x[$ .. $]);
19 }
20 auto f()() @safe pure nothrow { char[1] x = "_"; return x[].findLastSkip(' '); }
21 static if (isDIP1000) static assert(!__traits(compiles, { auto _ = f(); }));

Meta