|
Boost Users : |
From: dave_at_[hidden]
Date: 2006-06-14 19:06:20
hello (and thanks for previous help!),
I'm having some difficulty accessing the location of the beginning of a
successful partial match. in the callback below, match_results.position()
does give me the index of successful matches. How do i get it for
partial? The code does recognize a partial match but what[0].first seems
to be undefined on a partial match. The callback is called 3 times and
does identify the partial but have been totally unable to get that
index..Code is below, thanks alot!
Dave
bool regex_callback(const
boost::match_results<std::string::const_iterator>& what)
{
cout << "in callback, index is " << what.position(0) << endl;
if(!what[0].matched)
cout << "|--is partial " << endl;
return true;
}
int main(int argc, char *argv[])
{
string sMatchMe = "HELLO";
int theseflags=0;
boost::regex xreMatchme(sMatchMe, theseflags);
boost::cmatch xcmMatch;
string stupid = "sdfaHELLOdsfh*saHELLOdhfas1d3ahsdf%as&d!adfasdfsdHELL";
boost::sregex_iterator m1(stupid.begin(), stupid.end(), xreMatchme,
boost::match_default | boost::match_partial);
boost::sregex_iterator m2;
std::for_each(m1, m2, ®ex_callback);
return 1;
}
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