diff --git a/src/regex_impl.cc b/src/regex_impl.cc index c8c5bc05..26bbcb7e 100644 --- a/src/regex_impl.cc +++ b/src/regex_impl.cc @@ -441,7 +441,7 @@ private: if (*it++ != '}') parse_error("expected closing bracket"); m_pos = it; - return {ParsedRegex::Quantifier::RepeatMinMax, true, min, max}; + return {ParsedRegex::Quantifier::RepeatMinMax, check_greedy(), min, max}; } default: return {ParsedRegex::Quantifier::One}; } @@ -920,6 +920,23 @@ auto test_regex = UnitTest{[]{ kak_assert(not vm.exec("efg")); } + { + TestVM vm{R"((a{3,5})a+)"}; + kak_assert(vm.exec("aaaaaa", true, true)); + kak_assert(StringView{vm.m_captures[2], vm.m_captures[3]} == "aaaaa"); + } + + { + TestVM vm{R"((a{3,5}?)a+)"}; + kak_assert(vm.exec("aaaaaa", true, true)); + kak_assert(StringView{vm.m_captures[2], vm.m_captures[3]} == "aaa"); + } + + { + TestVM vm{R"((a{3,5}?)a)"}; + kak_assert(vm.exec("aaaa")); + } + { TestVM vm{R"(\d{3})"}; kak_assert(vm.exec("123"));