flag to specify if the matches should be in the resulting range
A lazy range of strings
import std.algorithm.comparison : equal; auto s1 = ", abc, de, fg, hi, "; assert(equal(splitter(s1, regex(", *")), ["", "abc", "de", "fg", "hi", ""]));
Split on a pattern, but keep the matches in the resulting range
import std.algorithm.comparison : equal; import std.typecons : Yes; auto pattern = regex(`([\.,])`); assert("2003.04.05" .splitter!(Yes.keepSeparators)(pattern) .equal(["2003", ".", "04", ".", "05"])); assert(",1,2,3" .splitter!(Yes.keepSeparators)(pattern) .equal([",", "1", ",", "2", ",", "3"]));
Splits a string r using a regular expression pat as a separator.