Boost logo

Boost Users :

Subject: Re: [Boost-users] problem with boost regex search
From: John Maddock (john_at_[hidden])
Date: 2009-02-24 04:09:23


> When I enter the following reg-ex: "^.*ab+c+d+" for the following text:
> "aaaabbbcccdddee" the text found is:"aaaabbbcccd". The text found should
> be:
> "aaaabbbcccddd". Digging deeper, its seems that the reg-ex function
> ignores
> the last character if it is a "+".
>
> This is just using boost::regex_search with the flags = boost::match_any
> and
> boost::match_not_null
>
> Am I missing something here?

Yep, match_any says to the regex engine "I don't care what the match is,
only if there is one", so it makes certain optimizations that result in the
shorter string being found. Stop using the match_any flag and you'll get
regular Perl-like behavior.

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