The OpenD Programming Language

lastIndexOfAny

Returns the index of the last occurrence of any of the elements in needles in haystack. If no element of needles is found, then -1 is returned. The stopIdx slices haystack in the following way s[0 .. stopIdx]. stopIdx represents a codeunit index in haystack. If the sequence ending at startIdx does not represent a well formed codepoint, then a std.utf.UTFException may be thrown.

  1. ptrdiff_t lastIndexOfAny(const(Char)[] haystack, const(Char2)[] needles, CaseSensitive cs)
    @safe pure
    ptrdiff_t
    lastIndexOfAny
    (
    Char
    Char2
    )
    (
    const(Char)[] haystack
    ,
    const(Char2)[] needles
    ,
    in CaseSensitive cs = Yes.caseSensitive
    )
    if (
    isSomeChar!Char &&
    )
  2. ptrdiff_t lastIndexOfAny(const(Char)[] haystack, const(Char2)[] needles, size_t stopIdx, CaseSensitive cs)

Parameters

haystack const(Char)[]

String to search for needles in.

needles const(Char2)[]

Strings to search for in haystack.

cs CaseSensitive

Indicates whether the comparisons are case sensitive.

Examples

ptrdiff_t i = "helloWorld".lastIndexOfAny("Wlo");
assert(i == 8);

i = "Foo öäöllo world".lastIndexOfAny("öF");
assert(i == 8);
import std.conv : to;

ptrdiff_t i = "helloWorld".lastIndexOfAny("Wlo", 4);
assert(i == 3);

i = "Foo öäöllo world".lastIndexOfAny("öF", 3);
assert(i == 0);

Meta