Index: libcxx/include/regex =================================================================== --- libcxx/include/regex +++ libcxx/include/regex @@ -3537,6 +3537,15 @@ default: if (__get_grammar(__flags_) == awk) __first = __parse_awk_escape(++__first, __last); + else + { + unsigned __val = __traits_.value(*__temp, 10); + if (__val >= 1 && __val <= 9) + { + __push_back_ref(__val); + __first = ++__temp; + } + } break; } } Index: libcxx/test/std/re/re.alg/re.alg.match/extended.pass.cpp =================================================================== --- libcxx/test/std/re/re.alg/re.alg.match/extended.pass.cpp +++ libcxx/test/std/re/re.alg/re.alg.match/extended.pass.cpp @@ -432,6 +432,24 @@ { std::cmatch m; const char s[] = "-ab,ab-"; + assert(std::regex_match(s, m, std::regex("-(.*),\\1-", std::regex_constants::extended))); + assert(m.size() == 2); + assert(!m.prefix().matched); + assert(m.prefix().first == s); + assert(m.prefix().second == m[0].first); + assert(!m.suffix().matched); + assert(m.suffix().first == m[0].second); + assert(m.suffix().second == m[0].second); + assert(m.length(0) >= 0 && static_cast(m.length(0)) == std::char_traits::length(s)); + assert(m.position(0) == 0); + assert(m.str(0) == s); + assert(m.length(1) == 2); + assert(m.position(1) == 1); + assert(m.str(1) == "ab"); + } + { + std::cmatch m; + const char s[] = "-ab,ab-"; assert(std::regex_match(s, m, std::regex("-.*,.*-", std::regex_constants::extended))); assert(m.size() == 1); assert(!m.prefix().matched); @@ -1100,6 +1118,24 @@ { std::wcmatch m; const wchar_t s[] = L"-ab,ab-"; + assert(std::regex_match(s, m, std::wregex(L"-(.*),\\1-", std::regex_constants::extended))); + assert(m.size() == 2); + assert(!m.prefix().matched); + assert(m.prefix().first == s); + assert(m.prefix().second == m[0].first); + assert(!m.suffix().matched); + assert(m.suffix().first == m[0].second); + assert(m.suffix().second == m[0].second); + assert(m.length(0) >= 0 && static_cast(m.length(0)) == std::char_traits::length(s)); + assert(m.position(0) == 0); + assert(m.str(0) == s); + assert(m.length(1) == 2); + assert(m.position(1) == 1); + assert(m.str(1) == L"ab"); + } + { + std::wcmatch m; + const wchar_t s[] = L"-ab,ab-"; assert(std::regex_match(s, m, std::wregex(L"-.*,.*-", std::regex_constants::extended))); assert(m.size() == 1); assert(!m.prefix().matched); Index: libcxx/test/std/re/re.alg/re.alg.search/extended.pass.cpp =================================================================== --- libcxx/test/std/re/re.alg/re.alg.search/extended.pass.cpp +++ libcxx/test/std/re/re.alg/re.alg.search/extended.pass.cpp @@ -495,6 +495,24 @@ { std::cmatch m; const char s[] = "-ab,ab-"; + assert(std::regex_search(s, m, std::regex("-(.*),\\1-", std::regex_constants::extended))); + assert(m.size() == 2); + assert(!m.prefix().matched); + assert(m.prefix().first == s); + assert(m.prefix().second == m[0].first); + assert(!m.suffix().matched); + assert(m.suffix().first == m[0].second); + assert(m.suffix().second == m[0].second); + assert(m.length(0) >= 0 && static_cast(m.length(0)) == std::char_traits::length(s)); + assert(m.position(0) == 0); + assert(m.str(0) == s); + assert(m.length(1) == 2); + assert(m.position(1) == 1); + assert(m.str(1) == "ab"); + } + { + std::cmatch m; + const char s[] = "-ab,ab-"; assert(std::regex_search(s, m, std::regex("-.*,.*-", std::regex_constants::extended))); assert(m.size() == 1); assert(!m.prefix().matched); @@ -1253,6 +1271,24 @@ { std::wcmatch m; const wchar_t s[] = L"-ab,ab-"; + assert(std::regex_search(s, m, std::wregex(L"-(.*),\\1-", std::regex_constants::extended))); + assert(m.size() == 2); + assert(!m.prefix().matched); + assert(m.prefix().first == s); + assert(m.prefix().second == m[0].first); + assert(!m.suffix().matched); + assert(m.suffix().first == m[0].second); + assert(m.suffix().second == m[0].second); + assert(m.length(0) >= 0 && static_cast(m.length(0)) == std::char_traits::length(s)); + assert(m.position(0) == 0); + assert(m.str(0) == s); + assert(m.length(1) == 2); + assert(m.position(1) == 1); + assert(m.str(1) == L"ab"); + } + { + std::wcmatch m; + const wchar_t s[] = L"-ab,ab-"; assert(std::regex_search(s, m, std::wregex(L"-.*,.*-", std::regex_constants::extended))); assert(m.size() == 1); assert(!m.prefix().matched);