I have question about match_result. How can I find out what was matched from the regular expression? In the boost documentation, the example for regex_search does something similar to this... regex needle("foo|bar"); string haystack("blah bar blah"); string::const_iterator start = haystack.begin(); string::const_iterator end = haystack.end(); boost::match_resultsstring::const_iterator what; *unsigned* *int* flags = boost::match_default; * while*(regex_search(start, end, what, expression, flags)) { // please output 'bar' string match(string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)); cout << "Found '" << match << "'\n"; start = what[0].second; flags |= boost::match_prev_avail; flags |= boost::match_not_bob; } However, this is outputing nothing. I also tried what.str(), but that gave me nothing too. Thanks again, Paul
string match(string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)); cout << "Found '" << match << "'\n"; However, this is outputing nothing. I also tried what.str(), but that gave me nothing too.
Your code is outputting $5+$6, but there aren't 6 marked sub-expressions in your expression. John.
participants (2)
-
John Maddock
-
Paul Scruby