C++中string類的成員函數find_first_not_of()

來源:互聯網
上載者:User
C++中string類的成員函數find_first_not_of()

函數原型:  

 

#include <string> 

  

size_type find_first_not_of(const string &str,size_type index =0 )const;  

size_type find_first_not_of(const Char* str,size_type index =0 )const;   

size_type find_first_not_of(const Char* str,size_type index,size_type num )const;   

size_type find_first_not_of(Char ch,size_type index =0 )const;   

 

 

函數find_first_not_of()功能如下:  

 

1.返回在字串中首次出現的不匹配str任何字元的首字元索引, 從index開始搜尋, 如果全部匹配則返回string::npos。   

2.從index開始起搜尋當前字串, 尋找其中與str前num個字元中的任意一個都不匹配的序列, 返回滿足條件的第一個字元索引, 否則返回string::npos。   

3.返回在當前字串中第一個不匹配ch字元的索引, 從index開始搜尋, 沒用收穫則返回string::npos。

 

註:string 類將 npos 定義為保證大於任何有效下標的值。npos = -1代表字串索引號的末尾一個。或者表示無效索引號。表示沒能尋找到

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.