string to search
substring to search for
Yes.caseSensitive or No.caseSensitive
the index of the last occurrence of sub in s. If sub is not found, then -1 is returned. The startIdx slices s in the following way s[0 .. startIdx]. startIdx represents a codeunit index in s.
If the sequence ending at startIdx does not represent a well formed codepoint, then a std.utf.UTFException may be thrown.
cs indicates whether the comparisons are case sensitive.
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);