Перевод этой страницы?:

Синтаксис:

     #include <string>
     size_type rfind( const string& str, size_type index = npos ) const;
     size_type rfind( const charT* str, size_type index = npos ) const;
     size_type rfind( const charT* str, size_type index, size_type num ) const;
     size_type rfind( charT ch, size_type index = npos ) const;

Функция rfind() возвращает позицию последнего вхождения str в текущую строку, выполняя обратный поиск начиная с index:

В следующем примере первый вызов rfind() возвращает string::npos, поскольку целевое слово не в пределах последних 8 символов строки. Однако, второй вызов возвращает 9, поскольку целевое слово находится среди последних 20 символов строки.

     string::size_type loc;
     string s = "My cat's breath smells like cat food.";
     loc = s.rfind( "breath", 8 );
     cout << "The word breath is at index " << loc << endl;
     loc = s.rfind( "breath", 20 );
     cout << "The word breath is at index " << loc << endl;

Смотрите также: find, find_first_not_of, find_first_of, find_last_not_of, find_last_of