Real simple question... for good programmers

Steven Schveighoffer schveiguy at gmail.com
Sun Oct 23 03:22:10 UTC 2022


On 10/22/22 5:53 PM, WhatMeWorry wrote:
> 
> 
> string[] tokens = userSID.output.split!isWhite;
> writeln("tokens = ", tokens);
> 
> tokens = ["SID", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", 
> "S-1-5-21-3823976785-3597194045-4221507747-1779", "", "", "", "", "", 
> "", "", ""]
> 
> 
> Is there a clever way that I can discard all the extra null strings in 
> the resultant string array?
> 
> I've been playing with isControl, whitespace, etc. Ready to rip my hair 
> out.

Try just split without the `isWhite`. If you look at the docs, you will see:

"When no delimiter is provided, strings are split into an array of 
words, using whitespace as delimiter. Runs of whitespace are merged 
together (no empty words are produced)."

-Steve



More information about the Digitalmars-d-learn mailing list