Re: "strstr" D equivalent

2022-07-29 Thread pascal111 via Digitalmars-d-learn
On Friday, 29 July 2022 at 15:39:16 UTC, Salih Dincer wrote: On Friday, 29 July 2022 at 14:14:54 UTC, pascal111 wrote: we won't find that there is a definition for it with just two parameters, so from where you got this new definition of this function?! This thread is about [UFCS](https://to

Re: "strstr" D equivalent

2022-07-29 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 29 July 2022 at 14:14:54 UTC, pascal111 wrote: we won't find that there is a definition for it with just two parameters, so from where you got this new definition of this function?! This thread is about [UFCS](https://tour.dlang.org/tour/en/gems/uniform-function-call-syntax-ufcs).

Re: "strstr" D equivalent

2022-07-29 Thread Paul Backus via Digitalmars-d-learn
On Friday, 29 July 2022 at 14:14:54 UTC, pascal111 wrote: and if I'm right, with returning back to the definitions of "indexOf" @ https://dlang.org/phobos/std_string.html#.indexOf we won't find that there is a definition for it with just two parameters, so from where you got this new definition

Re: "strstr" D equivalent

2022-07-29 Thread pascal111 via Digitalmars-d-learn
On Friday, 29 July 2022 at 13:44:47 UTC, Salih Dincer wrote: **Short version:** ```d import std.string; import std.stdio; void find (string str, string substr) { if(auto pos = str.indexOf(substr)) { writefln("found the string '%s' in '%s' at position: %s", substr, str, pos); }

Re: "strstr" D equivalent

2022-07-29 Thread Salih Dincer via Digitalmars-d-learn
**Short version:** ```d import std.string; import std.stdio; void find (string str, string substr) { if(auto pos = str.indexOf(substr)) { writefln("found the string '%s' in '%s' at position: %s", substr, str, pos); } else { writefln("the string '%s' was not found in '%s

Re: "strstr" D equivalent

2022-07-29 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 29 July 2022 at 11:23:55 UTC, pascal111 wrote: Is there an equivalent in D for C function "strstr" that return the first occurrence of a given string within another string? https://en.cppreference.com/w/c/string/byte/strstr https://dlang.org/library/std/string/index_of.html I neve

Re: "strstr" D equivalent

2022-07-29 Thread rassoc via Digitalmars-d-learn
On 7/29/22 13:23, pascal111 via Digitalmars-d-learn wrote: Is there an equivalent in D for C function "strstr" that return the first occurrence of a given string within another string? https://en.cppreference.com/w/c/string/byte/strstr You can use `find` from https://dlang.org/library/std/al

"strstr" D equivalent

2022-07-29 Thread pascal111 via Digitalmars-d-learn
Is there an equivalent in D for C function "strstr" that return the first occurrence of a given string within another string? https://en.cppreference.com/w/c/string/byte/strstr