splitterASCIIAmong

Non-decoding ASCII-separator-only variant of Phobos' splitter that .

TODO: generalize to separators being either chars or strings.

template splitterASCIIAmong(separators...)
splitterASCIIAmong
(
Range
)
(
return Range r
)
if (
is(typeof(Range.init[0 .. 0])) &&
is(typeof(Range.init[0]) : char)
&&
allSatisfy!(isASCII, separators)
)
if (
separators.length != 0 &&
isExpressions!separators
)

Members

Functions

splitterASCIIAmong
auto splitterASCIIAmong(Range r)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

import std.algorithm.comparison : equal;
import nxt.array_help : s;

assert(``.splitterASCIIAmong!(' ')
		 .empty);

assert(` `.splitterASCIIAmong!(' ')
		  .empty);

assert(`   `.splitterASCIIAmong!(' ')
			.empty);

assert(` - `.splitterASCIIAmong!(' ')
			.equal([`-`].s[]));

assert(`a`.splitterASCIIAmong!(' ')
		  .equal([`a`].s[]));

assert(` a `.splitterASCIIAmong!(' ')
			.equal([`a`].s[]));

assert(` a b `.splitterASCIIAmong!(' ')
			  .equal([`a`, `b`].s[]));

assert(` a_b `.splitterASCIIAmong!(' ')
			  .equal([`a_b`].s[]));

assert(` - aa   bb--c-d--e`.splitterASCIIAmong!(' ', '-')
							 .equal([`aa`, `bb`, `c`, `d`, `e`].s[]));

assert(` - aa   bb--c-_d--_e`.splitterASCIIAmong!(' ', '-', '_')
							 .equal([`aa`, `bb`, `c`, `d`, `e`].s[]));

assert(` - aa ///  bb--c-_d--_e`.splitterASCIIAmong!(' ', '-', '_', '/')
								.equal([`aa`, `bb`, `c`, `d`, `e`].s[]));

Meta