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)
但它返回空字符串.怎么了?