c++boostc++11lastindexof

Java-like lastIndexOf in c++


I performed some research on boost and c++ but could not locate anything relevant to my question. Is there an boost library or STL function that implements lastIndexOf?


Solution

  • std::string has the member function rfind() which searches from the end and returns the index if found or std::string::npos if not. From the linked reference page:

    Finds the last substring equal to the given character sequence.