From f1b493182447de852a18935793c69407d64e26ec Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 4 Oct 2017 22:30:22 +0800 Subject: [PATCH] Regex: Fix handling of non capturing groups (?:...) We were wrongly keeping the `:` as a literal content of the group --- src/regex_impl.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/regex_impl.cc b/src/regex_impl.cc index c7950bd8..9ede5989 100644 --- a/src/regex_impl.cc +++ b/src/regex_impl.cc @@ -189,7 +189,10 @@ private: { auto c = advance(); if (c == ':') + { + ++m_pos; content = disjunction(-1); + } else if (contains("=!<", c)) { bool behind = false; @@ -1005,6 +1008,12 @@ auto test_regex = UnitTest{[]{ kak_assert(not vm.exec("a]c")); kak_assert(vm.exec("abc")); } + + { + TestVM vm{R"((?:foo)+)"}; + kak_assert(vm.exec("foofoofoo")); + kak_assert(not vm.exec("barbarbar")); + } }}; }