splitter for strings

Chris via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 9 03:23:15 PDT 2014


On Monday, 9 June 2014 at 10:14:40 UTC, bearophile wrote:
> Chris:
>
>> auto word = "bla-bla";
>> auto parts = appender!(string[]);
>> w.splitter('-').copy(parts);
>> // parts.data.length == 3 ["bla", "", "bla"]
>
> With the current dmd 2.066alpha this code:
>
> void main() {
>     import std.stdio, std.string, std.algorithm;
>     const txt = "bla-bla";
>     txt.split("-").writeln;
>     txt.splitter("-").writeln;
>     txt.splitter('-').writeln;
> }
>
> Prints:
>
> ["bla", "bla"]
> ["bla", "bla"]
> ["bla", "bla"]
>
> Bye,
> bearophile

Ok, thanks. I'll keep that in mind for the next version.


More information about the Digitalmars-d-learn mailing list