You didn't specify any capture in your expression.
Given the structure of /proc/cpuinfo
, I'd probably prefer a line
oriented input, using std::getline
, rather than trying to do
everything at once. So you'ld end up with something like:
std::string line;
while ( std::getline( input, line ) ) {
static std::regex const procInfo( "model name\\s*: (.*)" );
std::cmatch results;
if ( std::regex_match( line, results, procInfo ) ) {
std::cout << "???" << " " << results[1] << std::endl;
}
}
It's not clear to me what you wanted as output. Probably, you also
have to capture the processor
line as well, and output that at the
start of the processor info line.
The important things to note are:
You need to accept varying amounts of white space: use "\\s*"
for 0 or more, "\\s+"
for one or more whitespace characters.
You need to use parentheses to delimit what you want to capture.
(FWIW: I'm actually basing my statements on boost::regex
, since I
don't have access to std::regex
. I think that they're pretty similar,
however, and that my statements above apply to both.)