public member function
<string>
std::basic_string::rfind string (1)size_type rfind (const basic_string& str, size_type pos = npos) const;c-string (2)
size_type rfind (const charT* s, size_type pos = npos) const;buffer (3)
size_type rfind (const charT* s, size_type pos, size_type n) const;character (4)
size_type rfind (charT c, size_type pos = npos) const;string (1)
size_type rfind (const basic_string& str, size_type pos = npos) const noexcept;c-string (2)
size_type rfind (const charT* s, size_type pos = npos) const;buffer (3)
size_type rfind (const charT* s, size_type pos, size_type n) const;character (4)
size_type rfind (charT c, size_type pos = npos) const noexcept;
Find last occurrence in string
Searches the basic_string for the last occurrence of the sequence specified by its arguments.When pos is specified, the search only includes sequences of characters that begin at or before position pos, ignoring any possible match beginning after pos.
The function uses traits_type::eq to determine character equivalences.
Member type size_type is an unsigned integral type.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// string::rfind
#include <iostream>
#include <string>
int main ()
{
std::string str ("The sixth sick sheik's sixth sheep's sick.");
std::string key ("sixth");
std::string::size_type found = str.rfind(key);
if (found!=std::string::npos)
str.replace (found,key.length(),"seventh");
std::cout << str << '\n';
return 0;
}
The sixth sick sheik's seventh sheep's sick.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4