persistent byLine
Jakob Ovrum
jakobovrum at gmail.com
Wed Jul 24 10:13:08 PDT 2013
On Monday, 22 July 2013 at 23:28:46 UTC, Jonathan M Davis wrote:
> splitter will do the job just fine as long as you don't care
> about /r/n -
> though we should arguably come up with a solution that works
> with /r/n
> (assuming that something in std.range or std.algorithm doesn't
> already do it,
> and I'm just not thinking of it at the moment).
>
> - Jonathan M Davis
std.regex.splitter can handle newlines more flexibly, e.g.:
void main()
{
import std.algorithm : equal;
import std.regex : ctRegex, splitter;
auto text = "one\ntwo\r\nthree";
auto newlinePattern = ctRegex!"[\r\n]+";
assert(text.splitter(newlinePattern).equal(["one", "two",
"three"]));
}
More information about the Digitalmars-d
mailing list