can anyone please show me an example about using regex (regex.h) in C/C++ to search and/or extracting subpattern in a regex.
in javascript, it will be something like
The only regular expressions readily available in C++ is boost::regex
, and that is what has been adopted for the next standard. And the syntax is:
boost::regex expr( "the string contains (\\d*) dots and (\\d*) chars" );
boost::smatch match;
if ( regex_match( text, match, expr ) ) {
// We have a match,
std::string dots = match[1];
std::string chars = match[2];
// ...
}