to delete the '\0' characters
Salih Dincer
salihdb at hotmail.com
Fri Sep 23 08:50:42 UTC 2022
On Thursday, 22 September 2022 at 21:49:36 UTC, Ali Çehreli wrote:
> On 9/22/22 14:31, Salih Dincer wrote:
>
> If you have multiple '\0' chars that you will continue looking
> for, how about the following?
It can be preferred in terms of working at ranges. But it isn't
useful in terms of having more than one character and moving away
from strings. For example:
```d
auto data = [ "hello", "and", "goodbye", "world" ];
auto hasZeros = data.joiner("\0\0").text; // ("hello\0\0",
"and\0\0", "goodbye\0\0", "world\0\0")
assert(hasZeros.count('\0') == 7);
assert(hasZeros.splitz.walkLength == data.length * 2 - 1);
auto range = hasZeros.splitz; // ("hello", "", "and", "",
"goodbye", "", "world")
```
SDB at 79
More information about the Digitalmars-d-learn
mailing list