Translations of this page?:

find_last_not_of

Syntax:

    #include <string>
    size_type find_last_not_of( const string& str, size_type index = npos ) const;
    size_type find_last_not_of( const charT* str, size_type index = npos ) const;
    size_type find_last_not_of( const charT* str, size_type index, size_type num ) const;
    size_type find_last_not_of( charT ch, size_type index = npos ) const;

find_last_not_of()関数は、以下の動作をします。

  • 現在の文字列の”index”番目から検索し、”str”内の文字列にマッチしない最後の文字の位置を返します。 “index”番目から逆に検索し、見つからなかったら”string::npos”を返します。
  • 現在の文字列の”index”番目から検索し、”str”内の文字列にマッチしない最後の文字の位置を返します。 “index”番目から逆に検索し、見つからなかったら”string::npos”を返します。
  • 現在の文字列の”index”番目から”num”文字の範囲を検索し、”str”内の文字列にマッチしない最後の文字の位置を返します。 “index”番目から逆に検索し、見つからなかったら”string::npos”を返します。
  • 現在の文字列の”index”番目から検索し、”ch”でない最後の文字の位置を返します。 “index”番目から逆に検索し、見つからなかったら”string::npos”を返します。

例えば、次のコードは、大小文字が混ざった文字列に対して、小文字でない文字を検索するコードです。

    string lower_case = "abcdefghijklmnopqrstuvwxyz";
    string str = "abcdefgABCDEFGhijklmnop";
    cout << "last non-lower-case letter in str at: " << str.find_last_not_of(lower_case) << endl;

出力結果

    last non-lower-case letter in str at: 13

Related Topics: find, find_first_not_of, find_first_of, find_last_of, rfind

 
• • • SitemapRecent changesRSScc