
Robert Mathews wrote:
"John Maddock" <john@johnmaddock.co.uk> wrote in message news:022901c55616$1b2bed20$030e1452@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 regex_match.) -- Eric Niebler Boost Consulting www.boost-consulting.com