Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2008-04-05 11:36:31


gast128 wrote:
> and another one: the regex::ECMAScript has value 0, so it can not be
> tested for in the following way:
>
> void show_flags(const std::tr1::regex& rrgx)
> {
> if ((rrgx.flags() & std::tr1::regex::ECMAScript) ==
> std::tr1::regex::ECMAScript)
> {
> //always true, since it has value 0
> }
> }

The value of zero is intentional: it was something that users were asking
for and ensures that:

regex e("text", perl|icase);

and

regex e("text, icase);

are equivalent (perl and ECMAScript expressions are treated the same in
Boost.Regex).

If you really want to extract out the regular expression "type" then use:

(e.flags() & (ECMAScript|basic|extended|awk|grep|egrep)) == ECMAScript

HTH, John.


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