The find_last_of() Family
The find_last_of() methods have these prototypes:
size_type find_last_of (const basic_string& str, size_type pos = npos) const noexcept;size_type find_last_of (const charT* s, size_type pos, size_type n) const;size_type find_last_of (const charT* s, size_type pos = npos) const;size_type find_last_of (charT c, size_type pos = npos) const noexcept;
These methods work like the corresponding rfind() methods, except that instead of looking for a match of the entire substring, they look for the last match for any single character in the substring.
Here’s code for finding the location of the last and next to last occurrences of any of the letters in "fluke" in a longer string:
string longer("That is a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access