|
Boost Users : |
Subject: [Boost-users] regex iterator question
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-03-30 02:25:52
I've got a need for regex and I would like to use it to extract tokens
matching a regular expresssion from a file stream. Seems like this would be
a common desire.
So first shot is
boost::regex_token_iterator<some_input_iterator>
This doesn't work since regex_token_iterator requires a bidirectional
iterator. Seems reasonable enough.
So next I comb through boost and find
#include <boost/spirit/iterator/multi_pass.hpp>
and try
boost::regex_token_iterator<
boost::spirit::multi_pass<some_input_iterator>
>
I'm thinking this is veeeeeery cool - maybe a 1000 lines of free code
included for the price of one.
But, doesn't work. multi_pass is a forward_trasversal iterator while
regex_token_iterator requires a bidirectional_trasversal_iterator. A huge
disappoint to come soooo close.
Thinking about it, this problem must come very often. How is it usually
addressed? There must be a simple bridge across this. In a pinch, I'll
just have to load the whole file into some sort collection, but I prefer the
ultimate unlimited file size solution.
Robert Ramey
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