string----------查找
来源:互联网 发布:磁头坏了 数据恢复 编辑:程序博客网 时间:2024/05/17 04:37
s.find(args) 严格匹配查找
s.rfind(args) 严格匹配查找
s.find_first_of(args, pos) 查找任意匹配字符,从pos开始找,
s.find_last_of(args, pos)
s.find_first_not_of(args) 查找任意不匹配字符
s.find_last_not_of(args)
#include <iostream>#include <string>using namespace std;int main( int argc, char** argv ){string name("AnnaBelle");name.find("nna");string::size_type pos1 = name.find("Belll");if( string::npos == pos1 )cout<<"not find"<<endl;elsecout<<pos1<<endl;name = "r2d%4Cd5";string num("0123456789");string::size_type pos = name.find_first_of(num);if( string::npos == pos )cout<<"not find"<<endl;elsecout<<"find pos:"<<pos<<endl;pos = 0;while( string::npos != (pos = name.find_first_of(num, pos)) ){cout<<"find pos:"<<pos<<endl;pos++;}pos = name.length();cout<<"nameLen:"<<name.length()<<" "<<name.size()<<endl;while( string::npos != (pos = name.find_last_of(num, pos)) ){cout<<"last_of:"<<name[pos]<<endl;--pos;}pos = 0;while( string::npos != (pos = name.find_first_not_of(num, pos)) ){cout<<name[pos]<<endl;++pos;}string letters("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");pos = 0;while( string::npos != (pos = name.find_first_of(letters, pos)) ){cout<<name[pos]<<endl;++pos;}pos = 0;while( string::npos != (pos = name.find_first_not_of(letters, pos)) ){cout<<name[pos]<<endl;++pos;}string strRiver("Mississippi");string::size_type FirstPos = strRiver.find("is");cout<<"firstPos:"<<FirstPos<<endl;string::size_type LastPos = strRiver.rfind("is");cout<<"LastPos:"<<LastPos<<endl;return 0;}
0 0
- string查找
- string----------查找
- 二分查找法,查找string
- string 查找子串
- string 查找函数
- string find查找函数
- C++ string查找示例
- String字符串查找操作
- String 查找函数c++
- 字符串查找String.IndexOf
- string类型的查找
- getResourceAsStream(String name)查找资源
- C++ String类查找函数
- string类的查找函数
- lua 查找字符 string.find()
- string的查找字符串操作
- string类的查找函数
- C++ string 字符串查找匹配
- 深入理解wince7中断处理过程
- 【张孝祥并发课程笔记】13:java5的同步工具简介
- 减小文件大小
- AsyncTask的介绍
- Android Service详解
- string----------查找
- UIButton设置背景图片(经过渲染的图片)与不渲染的区别
- 【张孝祥并发课程笔记】15:java5同步集合类的应用
- MyEclipse 6.0 反编译插件jad安装
- eclipse 和 google拼音输入法冲突问题
- 百度员工离职总结:如何做个好员工?
- 数据行列转置函数
- PHP发送HTTP请求(POST请求、GET请求)
- Building JavaScript Games for Phones Tablets and Desktop(2)-游戏编程基础