[Issue 16288] splitter() that doesn't eat sentinels

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Dec 31 00:14:41 PST 2016


https://issues.dlang.org/show_bug.cgi?id=16288

--- Comment #7 from greenify <greeenify at gmail.com> ---
> Doesn't implement desired behaviour.

Fair enough - I tried to make it similar to `splitter` in `std.regex`, but it
seems that even this didn't work out:

"a..b.c".splitter!(Yes.keepSeparators)(regex("[.]")).writeln

> ["a", ".", "", ".", "b", ".", "c"]

"a..b.c".splitter!(Yes.keepSeparators)('.').writeln;

> ["a", ".", ".", "b", ".", "c"]

>From the example you posted, you want it to yield sth. like this, right?

> ["a", ".", ".b", ".c"]

And there's another common use case - though that one is simply
splitter.filter!`a.empty`:

> ["a", "b", "c"]

However, at least the existing behavior for No.keepSeparators is the same:

"a..b.c".splitter!(No.keepSeparators)(regex("[.]")).writeln

> ["a", "", "b", "c"]

"a..b.c".splitter!(No.keepSeparators)('.').writeln;

> ["a", "", "b", "c"]

--


More information about the Digitalmars-d-bugs mailing list