C++ string中find ,rfind 等函数 用法总结及示例
#include <iostream> // std::cout#include <string> // std::stringint main (){ std::string str ("There are two needles in this haystack with needles."); std::string str2 ("needle"); // different member versions of find in the same order as above: std::size_t found = str.find(str2); if (found!=std::string::npos) std::cout << "first 'needle' found at: " << found << '\n'; found=str.find("needles are small",found+1,6); if (found!=std::string::npos) std::cout << "second 'needle' found at: " << found << '\n'; found=str.find("haystack"); if (found!=std::string::npos) std::cout << "'haystack' also found at: " << found << '\n'; found=str.find('.'); if (found!=std::string::npos) std::cout << "Period found at: " << found << '\n'; // let's replace the first needle: str.replace(str.find(str2),str2.length(),"preposition"); //replace 用法 std::cout << str << '\n'; return 0;}
其他同理
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow
C++ string中find ,rfind 等函数 用法总结及示例相关推荐
- string中find和find_first_of函数用法总结
一:find 函数原型: size_t find ( const string& str, size_t pos = 0 ) const; size_t find ( const char* ...
- getservbyname php,php中getservbyport与getservbyname函数用法实例
本文实例讲述了php中getservbyport与getservbyname函数用法.分享给大家供大家参考.具体如下: string getservbyport ( int $port , strin ...
- python中内置函数的用法_python中str内置函数用法总结
大家在使用python的过程中,应该在敲代码的时候经常遇到str内置函数,为了防止大家搞混,本文整理归纳了str内置函数.1字符串查找类:find.index:2.字符串判断类:islower.isa ...
- java split函数的用法,java拆分字符串_java中split拆分字符串函数用法
摘要 腾兴网为您分享:java中split拆分字符串函数用法,中信期货,掌上电力,星球联盟,淘集集等软件知识,以及韩剧精灵,每日英语听力vip,龙卷风收音机,优衣库,中国平煤神马集团协同办公系统,光晕 ...
- python threading join_Python中threading模块join函数用法实例分析
本文实例讲述了Python中threading模块join函数用法.分享给大家供大家参考.具体分析如下: join的作用是众所周知的,阻塞进程直到线程执行完毕.通用的做法是我们启动一批线程,最后joi ...
- C++string中的insert()插入函数
C++string中的insert()插入函数 basic_string& insert (size_type pos, const basic_string& str); 在原串下标 ...
- Mysql中rank类的函数用法
Mysql中rank类的函数用法 rank() over 作用:查出指定条件后的进行排名,条件相同排名相同,排名间断不连续. 说明:例如学生排名,使用这个函数,成绩相同的两名是并列,下一位同学空出所占 ...
- C#中ToInt32以及类似函数用法介绍
C#中ToInt32以及类似函数用法介绍 作用 程序举例 程序逻辑 程序代码 程序 作用 将指定的值转换为 32 位有符号整数.对应的还有ToInt16,ToInt64 指定的值可以是字符串.时间.位 ...
- python中的内置函数getattr()介绍及示例
python中的内置函数getattr()介绍及示例 其实getattr()这个方法最主要的作用是实现反射机制.也就是说可以通过字符串获取方法实例.这样,你就可以把一个类可能要调用的方法放在配置文件里 ...
最新文章
- 烂泥:学习ssh之ssh无密码登陆
- mysql表名不区分大小写_设置mysql表名不区分大小写
- cnpm在ubuntu19.10下面的安装以及vue.js中el的意思
- 【CodeForces - 124C】Prime Permutation(数学,思维,小结论)
- linux设备驱动之串口移植,Linux设备驱动之UART驱动结构
- 用贪心策略均分纸牌(洛谷P1031题题解,Java语言描述)
- ISA2004升级到ISA2006需要注意的事项
- [Apache]安装中出现的问题
- java保护性拷贝(effective java)
- php程序员如何转go,写给 PHP 程序员的 Go 入门教程
- 头歌实践平台:机器学习——支持向量回归
- 电路原理 的 一些基础知识
- 我国跨境电子商务的发展概念以及发展概况
- 四川大学计算机考研信息汇总
- appcan与java_AppCan试用体验
- 计算机信函 教案模板,一年级信息技术课教案模板三篇
- Ubuntu的共享文件夹
- 国际期货和国内期货的区别带招商
- JME3 官方教程翻译 - 自定义网格形状
- C语言英文背单词软件,C语言背单词程序