Real simple question... for good programmers

Daniel Daniel
Sat Oct 22 22:21:05 UTC 2022


On Saturday, 22 October 2022 at 22:01:09 UTC, Enjoys Math wrote:
> On Saturday, 22 October 2022 at 21:53:05 UTC, 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.
>> 	
>
> Why not `strip`?  Works on ranges:
> https://dlang.org/phobos/std_algorithm_mutation.html#.strip

Strip won't work because it only works on the beginning and ends 
of the range.  What you want is `remove`.  See my other MWE post.



More information about the Digitalmars-d-learn mailing list