std::cmatch res;
std::string str = "<h2>I'm a piece of text</h2>";
std::regex rx("<h(.)>([^<]+)");
std::regex_search(str.c_str(), res, rx);
std::cout << res[1] << ". " << res[2] << "\n";
这段简单的代码应该可以工作吗?对?显然它没有:
terminate called after throwing an instance of 'std::regex_error'
what(): regex_error
Aborted
编译器(gcc 4.7.0)错误还是我遗漏了什么?