Boost logo

Boost Users :

From: David McKelvie (david_at_[hidden])
Date: 2005-04-01 14:23:36


In Boost::regex, is it possible (by setting flags) to set up a syntax
which is like boost::regex::extended in that it finds the longest match,
but which also supports non-marking brackets i.e. (? ... ) ?

With

         boost::regex_constants::syntax_option_type sflags =
             boost::regex::extended
             | boost::regex::perlex // So that (?:...) non-marking brackets are allowed
             | boost::regex_constants::escape_in_lists;

         total_re.assign("(\n)|(.)|(\\.)|(\[[^\]]+\])", sflags);

regex_search on "[0-9]+" matches "["

while with

         boost::regex_constants::syntax_option_type sflags =
             boost::regex::extended
             | boost::regex_constants::escape_in_lists;

         total_re.assign("(\n)|(.)|(\\.)|(\[[^\]]+\])", sflags);

regex_search on "[0-9]+" matches "[0-9]" which is what I was wanting.
But I'd also like non-marking brackets, which dont work with extended
on its own.

I'd like non-marking brackets because,
I want users to be able to specify an ordered set of regexps, glom them together
into one regexp and then know the number of the longest regexp that matched.
Rather than parsing the user regexps myself and finding if they have used brackets
I tell users to use non-marking brackets.

In both cases

  boost::regex_constants::match_flag_type mflags =
    boost::match_default |
    boost::match_not_dot_newline |
    boost::match_continuous ;

Thanks,
        David


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