public member function
<string>
std::string::find_last_of string (1)size_t find_last_of (const string& str, size_t pos = npos) const;c-string (2)
size_t find_last_of (const char* s, size_t pos = npos) const;buffer (3)
size_t find_last_of (const char* s, size_t pos, size_t n) const;character (4)
size_t find_last_of (char c, size_t pos = npos) const;string (1)
size_t find_last_of (const string& str, size_t pos = npos) const noexcept;c-string (2)
size_t find_last_of (const char* s, size_t pos = npos) const;buffer (3)
size_t find_last_of (const char* s, size_t pos, size_t n) const;character (4)
size_t find_last_of (char c, size_t pos = npos) const noexcept;
Find character in string from the end
Searches the string for the last character that matches any of the characters specified in its arguments.When pos is specified, the search only includes characters at or before position pos, ignoring any possible occurrences after pos.
size_t is an unsigned integral type (the same as member type string::size_type).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// string::find_last_of
#include <iostream> // std::cout
#include <string> // std::string
#include <cstddef> // std::size_t
void SplitFilename (const std::string& str)
{
std::cout << "Splitting: " << str << '\n';
std::size_t found = str.find_last_of("/\\");
std::cout << " path: " << str.substr(0,found) << '\n';
std::cout << " file: " << str.substr(found+1) << '\n';
}
int main ()
{
std::string str1 ("/usr/bin/man");
std::string str2 ("c:\\windows\\winhelp.exe");
SplitFilename (str1);
SplitFilename (str2);
return 0;
}
Splitting: /usr/bin/man path: /usr/bin file: man Splitting: c:\windows\winhelp.exe path: c:\windows file: winhelp.exe
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