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()这个方法最主要的作用是实现反射机制.也就是说可以通过字符串获取方法实例.这样,你就可以把一个类可能要调用的方法放在配置文件里 ...
最新文章
- Java并发_volatile实现可见性但不保证原子性
- 让数字营销向人工智能借一双慧眼
- boost::array用法的测试程序
- 浏览器的一个请求从发送到返回都经历了什么?
- Convert Windows 32bit dirver to Windows 64bit
- Linux应用编程之共享内存实例
- 技术实践丨体验量子神经网络在自然语言处理中的应用
- 20.案例实战:为@Async实现一个自定义线程池
- 线上环境websocket连接地址_WebSocket:沙盒里的TCP
- sqlmap指定cookie_Sqlmap Cookie注入 教程
- php \n不能换行
- 单片机仿真软件proteus8安装与使用
- 男怕入错行 完美池宇峰畅谈创业点滴
- SNF快速开发平台2019-权限管理模型-平台服务(多平台\多组织\SAAS\多系统)
- linux文件压缩和打包
- 电子日历插件(阳历转阴历工具...)
- 「我是为“数据”去的京东」对话京东供应链首席科学家申作军
- WPF 实现圆形进度条
- Ueeshop:外贸网站推广优化方法和注意事项
- Brackets sequence UVA - 1626(区间DP)