Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2006-04-06 05:28:43


> In the snippet below, it works ok to loop thru m[num].matched, but I
> was wondering if there was a more direct way of getting the
> information about which match was "hit". (The real application is
> going to have about 70 possible subexpressions to match against,
> instead of just four.)

70!!! It wasn't really designed that kind of useage, and there isn't a
simple way to get say the lowest index sub-expression that was matched: even
with a full knowledge of the implementation it's not clear to me that it's
possible to do better than an O(N) algorithm.

You could I suppose group the sub-expressions together so you could use
something more like a binary search to find the one that matched:

((a|b|c)|(d|e|f))

Then

if(my_match[1].matched)
{
// must be a, b or c
}
else
{
// must be d e or f.
}

Sorry I can't be more helpful, but it's tempting to suggest that you use the
spirit parser libary rather than regexes.

John.


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