findSplitAfter

Array-specialization of findSplitAfter with default predicate.

@trusted
findSplitAfter
(
T
)
(
scope return inout(T)[] haystack
,
scope const T needle
)

Examples

char[] haystack;
auto r = haystack.findSplitAfter('_');
static assert(is(typeof(r.pre()) == char[]));
static assert(is(typeof(r.post()) == char[]));
assert(!r);
assert(!r.pre);
assert(!r.post);

auto f()() @safe pure nothrow { char[1] x = "_"; return x[].findSplitAfter(' '); }
static if (isDIP1000) static assert(!__traits(compiles, { auto _ = f(); }));
const(char)[] haystack;
auto r = haystack.findSplitAfter('_');
static assert(is(typeof(r.pre()) == const(char)[]));
static assert(is(typeof(r.post()) == const(char)[]));
assert(!r);
assert(!r.pre);
assert(!r.post);
auto r = "a*b".findSplitAfter('*');
static assert(is(typeof(r.pre()) == string));
static assert(is(typeof(r.post()) == string));
assert(r);
assert(r.pre == "a*");
assert(r.post == "b");

See Also

Meta