"strtok" D equivalent

pascal111 judas.the.messiah.111 at gmail.com
Thu Jul 28 21:03:55 UTC 2022


On Thursday, 28 July 2022 at 19:37:31 UTC, rikki cattermole wrote:
> I don't know of a D version, although it should be pretty easy 
> to write up yourself.
>
> But you can always use strtok itself.
>
> https://github.com/dlang/dmd/blob/09d04945bdbc0cba36f7bb1e19d5bd009d4b0ff2/druntime/src/core/stdc/string.d#L97
>
> Very similar to example given on the docs:
>
> ```d
> void main()
> {
>     import std.stdio, std.algorithm;
>     string input = "one + two * (three - four)!";
>     string delimiters = "!+-(*)";
>
>     foreach(value; input.splitWhen!((a, b) => 
> delimiters.canFind(b))) {
>         writeln(value);
>     }
> }
> ```

 From where can I get details about properties like "canFind" and 
"splitWhen" or other properties. The next link has mentioning for 
more properties:

https://dlang.org/spec/arrays.html


More information about the Digitalmars-d-learn mailing list