Search from the beginning : string find « string « C++ Tutorial






#include <string>
#include <iostream>

int main( ) {
   std::string s = "Search from the beginning";

   std::cout << s.find("ar") << '\n';            // Search from the beginning
}
2








15.19.string find
15.19.1.search a sub string
15.19.2.string.find(substring)
15.19.3.string.rfind(substring)
15.19.4.string.find_first_of( substring )
15.19.5.Find the first occurance
15.19.6.Find first out of
15.19.7.string.find_last_of(substring)
15.19.8.string.find_first_not_of( substring )
15.19.9.Find the first that's not in this set, starting from the end
15.19.10.Find the first of any of these chars starting from the end
15.19.11.Search from the beginning
15.19.12.Search from the end
15.19.13.Find the first of any of these chars
15.19.14.Find the first that's not in this set
15.19.15.find last occurrence of a character - equivalent of strrchr()
15.19.16.find first occurrence of a substring - equivalent of strstr()
15.19.17.find last occurrence of a substring - no C-string equivalent
15.19.18.find first occurrence of a character - equivalent of strchr()
15.19.19.Searching for the first occurrence of a substring in a string
15.19.20.Searching for the last occurrence of a substring in a string
15.19.21.Searching for the first occurrence of a letter in a string
15.19.22.Searching for the last occurrence of a letter in a string
15.19.23.Searching for the first occurrence of any character other than o, n, e, or space
15.19.24.Searching for the last occurrence of any character other than o, n, e, or space
15.19.25.Using find with reverse iteration