c ++ 11中的正则表达式

Max*_*rai 1 c++ regex linux c++11

我想解析Linux中的cpu信息.我写了这样的代码:

// Returns full data of the file in a string
std::string filedata = readFile("/proc/cpuinfo");

std::cmath results;
// In file that string looks like: 'model name : Intel ...'
std::regex reg("model name: *");
std::regex_search(filedata.c_str(), results, reg);

std::cout << results[0] << " " << results[1] << std::endl;
Run Code Online (Sandbox Code Playgroud)

但它返回空字符串.怎么了?

Som*_*ude 5

并非所有编译器都支持完整的C++ 11规范.值得注意的是,regex_search在GCC(从版本4.7.1开始)中不起作用,但它在VC++ 2010中起作用.