array of chars, wchars, or dchars or a slicable range
whether delimiter is included or not in the results
range of slices of the input range r
import std.array : array; string s = "Hello\nmy\rname\nis"; /* notice the call to 'array' to turn the lazy range created by lineSplitter comparable to the string[] created by splitLines. */ assert(lineSplitter(s).array == splitLines(s));
auto s = "\rpeter\n\rpaul\r\njerry\u2028ice\u2029cream\n\nsunday\nmon\u2030day\n"; auto lines = s.lineSplitter(); static immutable witness = ["", "peter", "", "paul", "jerry", "ice", "cream", "", "sunday", "mon\u2030day"]; uint i; foreach (line; lines) { assert(line == witness[i++]); } assert(i == witness.length);
Split an array or slicable range of characters into a range of lines using '\r', '\n', '\v', '\f', "\r\n", std.uni.lineSep, std.uni.paraSep and '\u0085' (NEL) as delimiters. If keepTerm is set to Yes.keepTerminator, then the delimiter is included in the slices returned.
Does not throw on invalid UTF; such is simply passed unchanged to the output.
Adheres to Unicode 7.0.
Does not allocate memory.