Boost logo

Boost Users :

Subject: Re: [Boost-users] [xpressive] static expression adding
From: Dave Jenkins (david_at_[hidden])
Date: 2009-02-12 11:02:16


"Eric Niebler" <eric_at_[hidden]> wrote in message
news:499444D3.2030806_at_boost-consulting.com...
>
> You can nest regular expressions to get the same behavior.
>
> sregex re0 = as_xpr('$');
> sregex re1 = re0 >> +_d;
> sregex re2 = re1 >> '.' >> _d >> _d;
>
> You lose most of the benefits of static regular expressions when you do
> this, though.
>

You can also use BOOST_PROTO_AUTO if you have a sub-expression that's used a
lot.
You have to include header <boost/proto/proto_typeof.hpp>.

For example:

//sregex re = '$' >> +_d >> '.' >> _d >> _d;

BOOST_PROTO_AUTO( re2, '.' >> _d >> _d);
sregex re = '$' >> +_d >> re2;

HTH,
Dave Jenkins


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