byWord

Returns an input range consisting of each non-blank word in the input argument.

byWord
(
Range
)
(
auto ref Range range
)
if (
isInputRange!Range &&
isSomeChar!(ElementType!Range)
)

Examples

1 auto text = "aw yess, this is so cool";
2 auto range = text.byWord;
3 assert(range.front == "aw");
4 range.popFront;
5 assert(range.front == "yess,");
6 range.popFront;
7 assert(range.front == "this");
8 auto nums = "0 1 2 3 4 5 6 7 8 9";
9 import std.algorithm.iteration: reduce;
10 assert(nums.byWord.reduce!((a,b) => a ~ b) == "0123456789");

Meta