程序输出下面是“它不匹配”但理想情况下它应该是“匹配”?
#include <iostream>
#include <string>
#include <regex>
using namespace std;
using namespace regex_constants;
int main()
{
string pattern = "[a]*";
try {
regex re(pattern, extended);
if(regex_match("aaaa", re))
cout << "It is matching" << endl;
else
cout << "It is not matching" << endl;
}catch(regex_error &e)
{
cout << e.what() << endl;
}
return 0;
}
答案 0 :(得分:0)
尝试使用Clang进行编译
clang++ -std=c++0x -stdlib=libc++ yourfile.cpp
Clang(3.3)支持正则表达式,GCC还没有。