string to search for sub in
substring to search for in s
specifies whether comparisons are case-sensitive (Yes.caseSensitive) or not (No.caseSensitive)
The index of the last 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 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.
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(lastIndexOf(s, "ll") == 2); assert(lastIndexOf(s, "Zo") == -1); assert(lastIndexOf(s, "lL", No.caseSensitive) == 2);
import std.typecons : No; string s = "Hello World"; assert(lastIndexOf(s, "ll", 4) == 2); assert(lastIndexOf(s, "Zo", 128) == -1); assert(lastIndexOf(s, "lL", 3, No.caseSensitive) == -1);
Searches for the last occurrence of a substring in a string.