diff --git a/include/boost/regex/v4/basic_regex_parser.hpp b/include/boost/regex/v4/basic_regex_parser.hpp index 27578988..ca1adde3 100644 --- a/include/boost/regex/v4/basic_regex_parser.hpp +++ b/include/boost/regex/v4/basic_regex_parser.hpp @@ -346,8 +346,13 @@ bool basic_regex_parser::parse_extended() ++m_position; return parse_repeat_range(false); case regex_constants::syntax_close_brace: - fail(regex_constants::error_brace, this->m_position - this->m_base, "Found a closing repetition operator } with no corresponding {."); - return false; + if((this->flags() & regbase::no_perl_ex) == regbase::no_perl_ex) + { + fail(regex_constants::error_brace, this->m_position - this->m_base, "Found a closing repetition operator } with no corresponding {."); + return false; + } + result = parse_literal(); + break; case regex_constants::syntax_or: return parse_alt(); case regex_constants::syntax_open_set: diff --git a/test/regress/test_simple_repeats.cpp b/test/regress/test_simple_repeats.cpp index d0e3a299..1691673a 100644 --- a/test/regress/test_simple_repeats.cpp +++ b/test/regress/test_simple_repeats.cpp @@ -172,6 +172,10 @@ void test_simple_repeats() TEST_REGEX_SEARCH("^a{0,1}?$", perl, "aaaaa", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("^(?:a){0,1}?$", perl, "aaaaa", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("^a(?:bc)?", perl, "abcbc", match_any|match_all, make_array(-2, -2)); + TEST_REGEX_SEARCH("a}", perl, "a}", match_default, make_array(0, 2, -2, -2)); + TEST_REGEX_SEARCH("a{12b", perl, "a{12bc", match_default, make_array(0, 5, -2, -2)); + TEST_INVALID_REGEX("a{b", extended); + TEST_INVALID_REGEX("a}b", extended); test_simple_repeats2(); }