std.algorithm.splitter improovement?

Peter Alexander peter.alexander.au at gmail.com
Sat Dec 14 08:31:38 PST 2013


On Saturday, 14 December 2013 at 16:00:06 UTC, seany wrote:
> the std.algorithm.splitter returns a blank or null (eg a null 
> string "") between two consecuting delimeters.
>
> for example, splitting "hello  world" (two spaces between 
> words) will return ["hello" , "", "world"]
>
> is there an improoved version of it, which wont return such a 
> blank/null when multiple delimeters are found consecutively? (i 
> tried to search the tango for d2, but i was not successful, 
> should there be one like this already, it must have escaped my 
> sight)

Just filter out the empty ranges:

r.splitter().filter!(x => !x.empty)


More information about the Digitalmars-d-learn mailing list