string::rfind
Find the last occurrence of a string within the string.
Synopsis
std::size_t
rfind(
string_view sv,
std::size_t pos = string::npos) const noexcept; (1)
std::size_t
rfind(
char ch,
std::size_t pos = string::npos) const noexcept; (2)
Description
-
(1) searches for the last substring equal to
sv
. -
(2) searches for the last occurrence of
ch
.
Both functions search for substrings fully contained within [begin(), begin() + pos)
.
Complexity
Linear.
Return Value
Index of the first character of the found substring or npos
if none was found.
Parameters
Name | Description |
---|---|
|
The string to search for. |
|
The index to start searching at. By default searches from the end of the string. |
|
The character to search for. |