[Issue 10772] std.regex.splitter generates spurious empty elements with empty delimiter

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 19 10:48:51 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=10772



--- Comment #7 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2013-12-19 10:48:49 PST ---
(In reply to comment #5)
> Arguably, 0-width splitting makes no sense: If it were to rigorously follow the
> rules, then you'd simply end up with an infinite amount of leading tokens.
> ["", "T", "E", "S", "T", ""]
> Makes no sense to me. Why is there an empty leading/trailing token, but none
> between each letter?
> 
> This means that in regards to 0-length splitting, it should either be an
> *error*, or have a *special behavior*

There is already special case that 0-width regular expression match advances
input by one codepoint. It's exactly this special case that produces the string
above, nothing to worry about.

> 
> std.algorithm.split simply special cases to do what seems most useful (what is
> documented by pearl, AFAIK). I think having regex do the same is most sensible.

Doing special-special case is kind of bad. The more I look at this the more
it's clear to me that we either have to decipher Perl's behaviour or give up.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list