Boost logo

Boost Users :

From: Paul Scruby (boost_at_[hidden])
Date: 2003-11-17 14:33:14


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_results<string::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



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net