Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-07-21 07:33:52


From: "John Maddock" <John_Maddock_at_[hidden]>
> >First, how do I use boost.regex to match several patterns, determining
the
> >pattern that produces the longest match?
>
> combine them into a single regex with the | operator and mark each one
with
> parenthesis:
>
> (expression1)|(expression2)|(expression3)
>
> etc.
>
> then if $1 is matched you know that it was expression1 that produced the
> longest match.

So far so good. How do I find out that expression2 produced the longest
match? It may not be $2. I'll have to parse expression1 myself. :-)

> With difficulty, you're going to have to provide either a bi-directional
> iterator, or a string, and that's going to mean some kind of buffering -
> you may want to use match_partial as a match flag if you're not sure how
> much input to buffer (take a look at the partial match section for a
couple
> of examples). I don't suppose you can use a memory mapped file instead of
> a stream?

Hmmm. Have you thought about exposing the NFA so I can 'feed' it a character
at a time and get a state back? This solves both problems.

--
Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk