From: Chris (chris_at_[hidden])
Date: 2001-04-29 21:25:29
I've been messing with boost's regex class, but I can't figure out
sub-expressions for the life of me. I understand that I call
regex_match(), and pass it a match_results, but I just don't
understand match_results - particularly struct sub_match .
For example, look at this little piece of code . . .
using namespace boost;
using namespace std;
int main(int argc, char* argv)
regex rxHeader("(\\w+), (\\w+)");
if (regex_match("Moose, Orangutang", matches, rxHeader))
cout << matches.first << endl;
I expect matches.first to return "Moose", the first match. But it
doesn't - it returns "Moose, Orangutang". matches.first returns
"Orangutang", which makes some sense.
Actually, I don't understand this whole first/second business in
sub_matches. In any other language, matches would just be a string
or something. But here, obviously things are being done differently,
and just don't understand what the scheme is here. I've read the docs
over and over, and I can't find a darn thing.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk