Fix regex_iterator and regex_replace to do what grep/sed do for multiple repeats when matching in POSIX mode.

Fixes #589.

[SVN r79339]
This commit is contained in:
John Maddock
2012-07-07 18:08:01 +00:00
parent e91bd45820
commit 3bfba1a7cf
3 changed files with 11 additions and 1 deletions

View File

@ -15,6 +15,12 @@ Currently open issues can be viewed [@https://svn.boost.org/trac/boost/query?sta
All issues including closed ones can be viewed [@https://svn.boost.org/trac/boost/query?status=assigned&status=closed&status=new&status=reopened&component=regex&order=priority&col=id&col=summary&col=status&col=type&col=milestone&col=component here].
[h4 Boost-1.51]
Fixed issues:
[@https://svn.boost.org/trac/boost/ticket/589 #589], [@https://svn.boost.org/trac/boost/ticket/7084 #7084],
[@https://svn.boost.org/trac/boost/ticket/7032 #7032].
[h4 Boost-1.50]
Fixed issue with `(?!)` not being a valid expression, and updated docs on what constitutes a valid conditional expression.

View File

@ -68,7 +68,7 @@ public:
// flags |= match_prev_avail;
BidirectionalIterator next_start = what[0].second;
match_flag_type f(flags);
if(!what.length())
if(!what.length() || (f & regex_constants::match_posix))
f |= regex_constants::match_not_initial_null;
//if(base != next_start)
// f |= regex_constants::match_not_bob;

View File

@ -190,5 +190,9 @@ void test_replace()
TEST_REGEX_REPLACE("(?:(?<one>a)|(?<one>b))", perl, " ...b,,", match_default, "$1.$2.$+{one}", " ....b.b,,");
TEST_REGEX_REPLACE("(?:(?<one>a)(?<one>b))", perl, " ...ab,,", match_default, "$1.$2.$+{one}", " ...a.b.a,,");
// See https://svn.boost.org/trac/boost/ticket/589
TEST_REGEX_REPLACE("(a*)", perl, "aabb", match_default, "{$1}", "{aa}{}b{}b{}");
TEST_REGEX_REPLACE("(a*)", extended, "aabb", match_default, "{$1}", "{aa}{}b{}b{}");
TEST_REGEX_REPLACE("(a*)", extended, "aabb", match_default|match_posix, "{$1}", "{aa}b{}b{}");
}