string or InputRange of characters to search in correct UTF format
character to search for
starting index to a well-formed code point
Yes.caseSensitive or No.caseSensitive
the index of the first occurrence of c in s with respect to the start index startIdx. If c is not found, then -1 is returned. If c is found the value of the returned index is at least startIdx. If the parameters are not valid UTF, the result will still be in the range [-1 .. s.length], but will not be reliable otherwise.
If the sequence starting at startIdx does not represent a well formed codepoint, then a std.utf.UTFException may be thrown.
import std.typecons : No; string s = "Hello World"; assert(indexOf(s, 'W') == 6); assert(indexOf(s, 'Z') == -1); assert(indexOf(s, 'w', No.caseSensitive) == 6);
import std.typecons : No; string s = "Hello World"; assert(indexOf(s, 'W', 4) == 6); assert(indexOf(s, 'Z', 100) == -1); assert(indexOf(s, 'w', 3, No.caseSensitive) == 6);
Searches for character in range.