string or ForwardRange of characters to search for sub in
substring to search for in s
index to a well-formed code point in s to start searching from; defaults to 0
The index of the first occurrence of sub in s. If sub is not found or startIdx is greater than or equal to s.length, then -1 is returned. If the arguments are not valid UTF, the result will still be either -1 or in the range [startIdx .. s.length], but will not be reliable otherwise.
If the sequence starting at startIdx does not represent a well-formed code point, then a std.utf.UTFException may be thrown.
Does not work with case-insensitive strings where the mapping of std.uni.toLower and std.uni.toUpper is not 1:1.
import std.typecons : No; string s = "Hello World"; assert(indexOf(s, "Wo", 4) == 6); assert(indexOf(s, "Zo", 100) == -1); assert(indexOf(s, "wo", 3, No.caseSensitive) == 6);
import std.typecons : No; string s = "Hello World"; assert(indexOf(s, "Wo") == 6); assert(indexOf(s, "Zo") == -1); assert(indexOf(s, "wO", No.caseSensitive) == 6);
Searches for a substring in a string or range.