I’m trying to use Perl’s regex memory features, which puts matched text in () in variables $1, $2…
Does anyone know how I can do this with Boost, maybe Boost saves the matched text in a different location?
The following line of code says that $1 is undefined.
boost::regex ex( aaa(b+)aaa, boost::regex::perl );
if(boost::regex_search( line ,ex ))
set_value( $1 ); // Here $1 should contain all the b's matched in the parenthesis
Thanks,
Joe
You will want to use a separate overload of
boost::regex_searchIn particular you want one where you pass in a
boost::match_resultsstructure (by reference). This will be populated with the sub-expressions (and the portion of the input that was matched), as long as the search is successful.