How to find the right function in the Phobos library?
Ron Tarrant
rontarrant at gmail.com
Sat Aug 17 06:42:24 UTC 2024
On Saturday, 17 August 2024 at 05:28:37 UTC, Bruce wrote:
> Example.
> I want to find the index of an item in an array.
```
import std.stdio;
import std.string;
void main()
{
string text = "Hello, World!";
string searchSubstring = "World";
ptrdiff_t index = text.indexOf(searchSubstring);
if (index != -1)
{
writeln("The substring '", searchSubstring, "' found at
index ", index);
}
else
{
writeln("The substring '", searchSubstring, "' not found in
the string.");
}
}
```
More information about the Digitalmars-d-learn
mailing list