版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/liangzhao_jay/article/details/87780014
c++11特性, 需要VS2014 及以上 , 或者 GCC4.8 及以上 版本编译器。
#include <iostream>
#include <regex>
#include <string>
using std::string;
using std::cout;
void testReg()
{
std::regex reg("how\\smany\\sCredits\\sis.*");
string str1("how many Credits is glob prok Silver ? ");
std::smatch smatch1;
if(std::regex_match(str1, smatch1, reg))
{
cout<<"success!\n";
}
else
{
cout<<"fail!\n";
}
}
int main()
{
testReg();
return 0;
}