string or InputRange of characters to search for c in
character to search for in s
specifies whether comparisons are case-sensitive (Yes.caseSensitive) or not (No.caseSensitive).
If c is found in s, then the index of its first occurrence is returned. If c is not found or startIdx is greater than or equal to s.length, then -1 is returned. If the parameters 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.
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 a character in a string or range.