C ++中是否有类似string.contains()的东西? [英] Is there anything like string.contains() in c++?
本文介绍了C ++中是否有类似string.contains()的东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在c ++中是否有类似string.contains()的东西?
Is there anything like string.contains() in c++?
推荐答案
我无法确切回答,因为您的帖子中有关于除了名称,"string.contains()"的作用是什么.我建议看一下std :: string :: find()看看是否合适.
干杯,
Ash
I can''t answer definitively as there''s clue in your post as to what "string.contains()" does apart from the name. I''d suggest looking at std::string::find() and see if that fits the bill.
Cheers,
Ash
如果使用boost libary,则可以这样使用包含".
示例:
#include< boost/algorithm/string.hpp>
使用名称空间std;
使用命名空间boost;
字符串str1("hello");
字符串str2("el");
bool结果= contains(str1,str2);
在boost :: algorithm中找到有用的东西.
干杯.
If you use boost libary, you can use "contains" like this.
Example:
#include <boost/algorithm/string.hpp>
using namespace std;
using namespace boost;
string str1("hello");
string str2("el");
bool result = contains(str1, str2);
Find something usefull in boost::algorithm.
Cheers.
我记得,在大学一年级实践考试中,我不得不开发一个函数来找出所需的字符串是否存在.
为什么问这个问题?
如果是家庭作业,最好自己动手做.
I can remember, in university first year practical exam I had to develop a function to find out whether the desired string exists or not.
Why are you asking this question?
if it is a homework better do it yourself.
这篇关于C ++中是否有类似string.contains()的东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文