Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2005-05-20 16:39:36

Robert Mathews wrote:
> "John Maddock" <john_at_[hidden]> wrote in message
> news:022901c55616$1b2bed20$030e1452_at_fuji...
> > I noticed some surprising behavior with match_partial and regex_search.
> > Consider:
>>regex e("abc|b");
>>string str("ab");
>>smatch what;
>>if(regex_search(str, what, e, match_default | match_partial))
>> cout << (what[0].matched ? "full" : "partial") << '\n';
>>This code displays "partial". Clearly, regex_search is bombing out just as
>>soon as it finds a match, partial or otherwise. But in this case, if it
>>kept looking, it would find a full match.
> Very stupid question, I guess, but I had to ask:
> The regex "abc|b" means either "abc" or "b". How could "ab" provide a full
> match if it kept looking ... ?

It could match the "b" in "ab". (We're talking about regex_search, not

Eric Niebler
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at