我正在使用新版本的 boost 1.42,我想使用带有命名子组的正则表达式。下面举个例子。
std::string line("match this here FIELD=VALUE in the middle");
boost::regex rgx("FIELD=(?<VAL>\\w+)", boost::regex::perl );
boost::smatch thisMatch;
boost::regex_search( line, thisMatch, rgx );
你知道如何获取比赛的内容吗?传统的方式是
std::string result( mtch[1].first, mtch[1].second );
但我不想用这种方式。
我想在 Perl 和一般的正则表达式中像往常一样使用子组的名称。我试过这个,但它没有用。
std::string result( mtch["VAL"].first, mtch["VAL"].second );
您知道如何使用子组的名称获取值吗?
谢谢AFG