find: 查找子串在字符串中第一次出现的位置,必须匹配完整子串。
string s = "Hello, world!";
int npos = s.find("world");
std::cout << npos<<"\n";
rfind : 查找子串在字符串中最后一次出现的位置,必须匹配完整子串。
string s = "Hello, world!";
int npos1 = s.rfind("world");
std::cout << npos1 << "\n";
find_first_of : 查找子串中任意字符在字符串中第一次出现的位置,任意子串中字符。
string s = "Hello, world!";
int npos2 = s.find_first_of("Hello World!");
std::cout << npos2 << "\n";
find_last_of : 查找子串中任意字符在字符串中最后一次出现的位置,任意子串中字符。
string s = "Hello, world!";
int npos3 = s.find_last_of("Hello World!");
std::cout << npos3 << "\n";
find_first_not_of : 查找字符串中第一个不包含在待查找字符串中的字符的位置,也是任意字符。
string s = "Hello, world!";
int npos4 = s.find_first_not_of("HeLo");
std::cout << npos4 << "\n";
find_last_not_of : 查找字符串中最后一个不属于待查找字符串中的字符的位置,也是任意字符
string s = "Hello, world!";
int npos5 = s.find_last_not_of("HeLo");
std::cout << npos5 << "\n";