Searching s1.find_first_not_of(s2); first element of s1 not in s2 s1.find_last_not_of(s2); last element of s1 not in s2 std::string s1 = "abcdef---defghi"; std::string s2 = "ghiabc"; s1.find_first_of(s2); // returns 3 s1.find_last_of(s2); // returns 11