View source code
Display the source code in std/string.d from which this page was generated on
github.
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.
Page wiki
View or edit the community-maintained wiki page associated with this page.
std.string.index_of_neither
- multiple declarations
- Function indexOfNeither
- Function indexOfNeither
Function indexOfNeither
Returns the index of the first occurence of any character not an elements
in
in needles
. If all element of haystack
are
element of haystack
needles
-1
is returned.
Prototype
ptrdiff_t indexOfNeither(Char, Char2)( const(Char)[] haystack, const(Char2)[] needles, size_t startIdx, CaseSensitive cs = CaseSensitive.yes ) pure @safe if (isSomeChar!Char && isSomeChar!Char2);
Parameters
Name | Description |
---|---|
haystack | String to search for needles in. |
needles | Strings to search for in haystack . |
startIdx | slices haystack like this . If
the startIdx is greater equal the length of haystack the functions
returns -1 . |
cs | Indicates whether the comparisons are case sensitive. |
Example
assert(indexOfNeither("abba", "a", 2) == 2); assert(indexOfNeither("def", "de", 1) == 2); assert(indexOfNeither("dfefffg", "dfe", 4) == 6);
Function indexOfNeither
Returns the index of the first occurence of any character not an elements
in
in needles
. If all element of haystack
are
element of haystack
needles
-1
is returned.
Prototype
ptrdiff_t indexOfNeither(Char, Char2)( const(Char)[] haystack, const(Char2)[] needles, CaseSensitive cs = CaseSensitive.yes ) pure @safe if (isSomeChar!Char && isSomeChar!Char2);
Parameters
Name | Description |
---|---|
haystack | String to search for needles in. |
needles | Strings to search for in haystack . |
cs | Indicates whether the comparisons are case sensitive. |
Example
assert(indexOfNeither("def", "a") == 0); assert(indexOfNeither("def", "de") == 2); assert(indexOfNeither("dfefffg", "dfe") == 6);
Authors
Walter Bright, Andrei Alexandrescu, and Jonathan M Davis