C++stringの検索関数findとfind_first_of関数の違い

2636 ワード

string (1)  
size_t find_first_of (const string& str, size_t pos = 0) const noexcept;
c-string (2)    
size_t find_first_of (const char* s, size_t pos = 0) const;
buffer (3)  
size_t find_first_of (const char* s, size_t pos, size_t n) const;
character (4)   
size_t find_first_of (char c, size_t pos = 0) const noexcept;

find_first_of関数:親列で指定した位置から検索を開始し、遭遇した文字がターゲット列の任意の文字と同じである場合、検索に成功し、その文字の位置を返します.
string (1)  
size_t find (const string& str, size_t pos = 0) const noexcept;
c-string (2)    
size_t find (const char* s, size_t pos = 0) const;
buffer (3)  
size_t find (const char* s, size_t pos, size_type n) const;
character (4)   
size_t find (char c, size_t pos = 0) const noexcept;

find関数:指定した位置から親列で文字または文字列を検索します.文字列を検索するときは、ターゲット列が親列のサブ列であることを保証します.次はcplusplusです.comの説明:
Notice that unlike member find_first_of, whenever more than one character is being searched for, it is not enough that just one of these characters match, but the entire sequence must match.
注意:rfindはfindの使用方法と似ています.find_last_of、find_first_not_of、find_last_not_ofとfind_first_of使用方法は似ています.