Boost logo

Boost :

From: John Maddock (John_Maddock_at_[hidden])
Date: 2001-07-21 05:25:46


>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.

>Second, how do I convince the library to work with a istream? Read N
>characters, match, read N * 2 characters, match, and so on? There has to
be
>a better way. :-) I don't need an iterator pair back, only the number of
>reads the library has performed.

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?

- John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/


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