string 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 last 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 ending 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(lastIndexOf(s, 'l') == 9); assert(lastIndexOf(s, 'Z') == -1); assert(lastIndexOf(s, 'L', No.caseSensitive) == 9);
import std.typecons : No; string s = "Hello World"; assert(lastIndexOf(s, 'l', 4) == 3); assert(lastIndexOf(s, 'Z', 1337) == -1); assert(lastIndexOf(s, 'L', 7, No.caseSensitive) == 3);
Searches for the last occurrence of a character in a string.