The OpenD Programming Language

indexOfNeither

Returns the index of the first occurrence of any character not an elements in needles in haystack. If all element of haystack are element of needles -1 is returned.

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

Parameters

haystack const(Char)[]

String to search for needles in.

needles const(Char2)[]

Strings to search for in haystack.

startIdx size_t

slices haystack like this haystack[startIdx .. $]. If the startIdx is greater than or equal to the length of haystack the functions returns -1.

cs CaseSensitive

Indicates whether the comparisons are case sensitive.

Examples

assert(indexOfNeither("abba", "a", 2) == 2);
assert(indexOfNeither("def", "de", 1) == 2);
assert(indexOfNeither("dfefffg", "dfe", 4) == 6);
assert(indexOfNeither("def", "a") == 0);
assert(indexOfNeither("def", "de") == 2);
assert(indexOfNeither("dfefffg", "dfe") == 6);

Meta