On Wednesday, 28 October 2015 at 00:07:23 UTC, sigod wrote:
Only removed `filter` from code.

You know, I was just writing an answer for this and I kinda changed my mind. Without filter... I think splitter.splitter ought to work.

The implementation requires slicing unless you pass it a predicate. Only that overload works on minimal forward ranges.

This compiles:

        import std.algorithm;
        import std.array;
        import std.stdio;

        void main(string[] args)
        {
                auto t = "foo\nbar\ncool---beans"
                        .splitter('\n')
                        .filter!(e => e.length)
                        .splitter!(a => a == "bar")
                ;
                writeln(t);
        }

It returns [["foo"], ["cool---beans"]]; it split it on the "bar" line in the middle.

I think that might be basically what you want.

Reply via email to