C++ 中的正则表达式搜索序列



任何人都可以帮助我在 C++11 中使用正则表达式吗? 例如,我有一个字符串zoo,我想在另一个字符串中查找单词zoo subsequently,让我们说abczdef o xyzobs

如果找到我想打印找到其他找不到,如何使用C ++执行此操作

string a="abczdefoxyzobs";
string b="zoo",r="";
//if your string size is too small add .* by hand if not use for
for(int i=0;i<b.size();i++)
r=r+".*"+b[i];
r+=".*";
regex e(r);
if(regex_match(a,e))
cout<<"Foundn";
else
cout<<"Not foundn";

最新更新