char[] haystack; auto r = haystack.findSplitAfter('_'); 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[].findSplitAfter(' '); } static if (hasPreviewDIP1000) static assert(!__traits(compiles, { auto _ = f(); })); }
const(char)[] haystack; auto r = haystack.findSplitAfter('_'); 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"; auto r = haystack.findSplitAfter('*'); static assert(is(typeof(r.pre()) == typeof(haystack))); static assert(is(typeof(r.post()) == typeof(haystack))); assert(r); assert(r.pre == "a*"); assert(r.post == "b");
https://forum.dlang.org/post/dhxwgtaubzbmjaqjmnmq@forum.dlang.org https://forum.dlang.org/post/zhgajqdhybtbufeiiofp@forum.dlang.org
Array-specialization of findSplitAfter with default predicate.