View source code
Display the source code in std/string.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Function std.string.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.

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

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

Parameters

NameDescription
haystack String to search for needles in.
needles Strings to search for in haystack.
startIdx slices haystack like this haystack[startIdx .. $]. If the startIdx is greater than or equal to the length of haystack the functions returns -1.
cs Indicates whether the comparisons are case sensitive.

Example

writeln(indexOfNeither("abba", "a", 2)); // 2
writeln(indexOfNeither("def", "de", 1)); // 2
writeln(indexOfNeither("dfefffg", "dfe", 4)); // 6

Example

writeln(indexOfNeither("def", "a")); // 0
writeln(indexOfNeither("def", "de")); // 2
writeln(indexOfNeither("dfefffg", "dfe")); // 6

Authors

Walter Bright, Andrei Alexandrescu, Jonathan M Davis, and David L. 'SpottedTiger' Davis

License

Boost License 1.0.