[C ++] string-type lookup Functions
String-type lookup function: int find (char c, int pos = 0) const; // start from pos to find the position of character c in the current string int find (const char * s, int pos = 0) const; // start from pos to find the position of string s in the current string int find (const char * s, int pos, int n) const; // start from pos to find the position of the First n characters in string s in the current string int find (const string & s, int pos = 0) const; // start from pos to find the position of string s in the current string // return the position when the query is successful. If the query fails, return the string: npos value int rfind (char c, int pos = npos) const; // search for the position of character c in the current string from the back to the back of the pos (const char * s, Int pos = npos) const; int rfind (const char * s, int pos, int n = npos) const; int rfind (const string & s, int pos = npos) const; // start from the pos and start from the back to the front to find the position of the string consisting of the First n characters in string s in the current string. The position of the string is returned successfully. If the position fails, the string is returned :: npos value int find_first_of (char c, int pos = 0) const; // search for the position where character c appears for the first time from pos int find_first_of (const char * s, int pos = 0) const; int find_first_of (const char * s, int pos, int n) const; int find_first_of (const string & s, I Nt pos = 0) const; // start from pos to find the position of the first character in the array of the First n characters in s in the current string. String: npos int find_first_not_of (char c, int pos = 0) const; int find_first_not_of (const char * s, int pos = 0) const; int find_first_not_of (const char * s, int pos, int n) const; int find_first_not_of (const string & s, int pos = 0) const; // find the position of the first character not in string s from the current string, and return string: npos int find_last_of (char c, int pos = npos) const; int find_last_of (const char * s, int pos = npos) const; int find_last_of (const char * s, int pos, int n = npos) const; int find_last_of (const string & s, int pos = npos) const; int find_last_not_of (char c, int pos = npos) const; int find_last_not_of (const char * s, int pos = npos) const; int find_last_not_of (const char * s, int pos, int n) const; int find_last_not_of (const string & s, int pos = npos) const; // find_last_of and find_last_not_of are similar to find_first_of and find_first_not_of, but they are searched forward from the back.
An example is attached below:
#include
#include
using namespace std;void main(){ string a="0AA00AA00"; char str[]="AA"; int pos=a.find(str,2); cout<