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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Dec 18 13:10:35 PST 2013


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


Dmitry Olshansky <dmitry.olsh at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmitry.olsh at gmail.com


--- Comment #1 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2013-12-18 13:10:33 PST ---
(In reply to comment #0)
> CODE:
> --------
> void main() {
>     import std.string, std.stdio, std.regex;
>     string s = "test";
>     writeln(std.regex.splitter(s.toUpper, regex("")));
> }
> --------
> 
> Output:
> --------
> ["", "T", "E", "S", "T", ""]
> --------
> 
> The first and last empty elements should not be included in the result. Cf.
> Perl's split(//, "test").

The matter is more or less trivial, the only problem is what you actually want
me to do?

No matter how I read this passage:
http://perldoc.perl.org/functions/split.html
I can only gather that 0-width match at front of input is never produced
(okay..). What the heck must be happening with the one at the end isn't clear
to me at all.

Given that the following test produces ["T", "E", "S", "T"] we may just ignore
0-width match at both ends to be in line. The behaviour needs to be documented
though. Anyway - seems good?

void main() {
    import std.string, std.algorithm, std.stdio;//, std.regex;
    string s = "test";
    writeln(splitter(s.toUpper, ""));
}

-- 
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