std.string.index_of - multiple declarations
- Function indexOf
- Function indexOf
- Function indexOf
- Function indexOf
Function indexOf
Searches for character in range.
Prototype
ptrdiff_t indexOf(Range)( Range s, dchar c, CaseSensitive cs = CaseSensitive.yes ) if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range));
Parameters
| Name | Description |
|---|---|
| s | string or InputRange of characters to search in correct UTF format |
| c | character to search for |
| cs | CaseSensitive.yes or CaseSensitive.no |
Returns
the index of the first occurrence of in c. If s
is not found, then c-1 is returned.
If the parameters are not valid UTF, the result will still
be in the range [-1 .. s.length], but will not be reliable otherwise.
Function indexOf
Prototype
ptrdiff_t indexOf(Char1, Char2)( const(Char1)[] s, const(Char2)[] sub, size_t startIdx, CaseSensitive cs = CaseSensitive.yes ) @safe if (isSomeChar!Char1 && isSomeChar!Char2);
Parameters
| Name | Description |
|---|---|
| s | string to search |
| sub | substring to search for |
| startIdx | the index into s to start searching from |
| cs | CaseSensitive.yes or CaseSensitive.no |
Returns
The index of the first occurrence of in sub with
respect to the start index s. If startIdx is not found, then
sub-1 is returned. If is found the value of the returned index
is at least sub. startIdx represents a codeunit index in
startIdx. If the sequence starting at s does not represent a well
formed codepoint, then a startIdxstd.utf.UTFException may be thrown.
indicates whether the comparisons are case sensitive.
cs
Function indexOf
Searches for substring in .
s
Prototype
ptrdiff_t indexOf(Range, Char)( Range s, const(Char)[] sub, CaseSensitive cs = CaseSensitive.yes ) if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && isSomeChar!Char);
Parameters
| Name | Description |
|---|---|
| s | string or ForwardRange of characters to search in correct UTF format |
| sub | substring to search for |
| cs | CaseSensitive.yes or CaseSensitive.no |
Returns
the index of the first occurrence of in sub. If s
is not found, then sub-1 is returned.
If the arguments are not valid UTF, the result will still
be in the range [-1 .. s.length], but will not be reliable otherwise.
Bugs
Does not work with case insensitive strings where the mapping of tolower and toupper is not 1:1.
Function indexOf
Searches for character in range starting at index startIdx.
Prototype
ptrdiff_t indexOf(Range)( Range s, dchar c, size_t startIdx, CaseSensitive cs = CaseSensitive.yes ) if (isInputRange!Range && isSomeChar!(ElementEncodingType!Range));
Parameters
| Name | Description |
|---|---|
| s | string or InputRange of characters to search in correct UTF format |
| c | character to search for |
| startIdx | starting index to a well-formed code point |
| cs | CaseSensitive.yes or CaseSensitive.no |
Returns
the index of the first occurrence of in c. If s
is not found, then c-1 is returned.
If the parameters are not valid UTF, the result will still
be in the range [-1 .. s.length], but will not be reliable otherwise.
Authors
Walter Bright, Andrei Alexandrescu, and Jonathan M Davis