findLastSplitAfter

Array-specialization of findLastSplitAfter with default predicate.

Examples

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

See Also

Meta