Syntax:
#include <string> size_type find_first_not_of( const string& str, size_type index = 0 ) const; size_type find_first_not_of( const charT* str, size_type index = 0 ) const; size_type find_first_not_of( const charT* str, size_type index, size_type num ) const; size_type find_first_not_of( charT ch, size_type index = 0 ) const;
find_first_not_of()関数は、いずれかの動作をします。
例えば、次のコードでは、”小文字とスペース、カンマ、ハイフン”以外の文字がテキストに含まれていないか検索します。
string lower_case = "abcdefghijklmnopqrstuvwxyz ,-"; string str = "this is the lower-case part, AND THIS IS THE UPPER-CASE PART"; cout << "first non-lower-case letter in str at: " << str.find_first_not_of(lower_case) << endl;
実行すると、find_first_not_of()が、大文字の文字を見つけ、29文字目にあることが出力されます。
first non-lower-case letter in str at: 29
Related Topics: find, find_first_not_of, find_first_of, find_last_not_of, find_last_of, rfind