getting names subgroups
Posted
by Abruzzo Forte e Gentile
on Stack Overflow
See other posts from Stack Overflow
or by Abruzzo Forte e Gentile
Published on 2010-03-12T10:45:47Z
Indexed on
2010/03/12
10:47 UTC
Read the original article
Hit count: 267
boost-regex
Hi All
I am working with the new version of boost 1.42 and I want to use regex with named sub groups. Below an example.
std::string line("match this here FIELD=VALUE in the middle"); boost::regex rgx("FIELD=(?\\w+)", boost::regex::perl ); boost::smatch thisMatch; boost::regex_searh( line, thisMatch, rgx );
Do you know how to get the content of the match ? The traditional way is
std::string result( mtch["VAL"].first, mtch["VAL"].second );but i don't want to use this way.
I want to use the name of the subgroups as usual in Perl and in regex in general. I tried this, but it didn't work.
std::string result( mtch["VAL"].first, mtch["VAL"].second );
Do you know how to get the value using the name of the subgroup?
Thanks AFG
© Stack Overflow or respective owner