**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'", substr, str);
    }
}

void main() {
    string str = "one two three";
    str.find("two");
    str.find("");
    str.find("nine");
    str.find("n");
}
```
SDB@79

Reply via email to