Regex: support escaping characters in character classes
This commit is contained in:
parent
3d2262bebf
commit
76dcfd5c52
|
@ -307,7 +307,7 @@ private:
|
|||
Vector<std::pair<wctype_t, bool>> ctypes;
|
||||
while (m_pos != m_regex.end() and *m_pos != ']')
|
||||
{
|
||||
const auto cp = *m_pos++;
|
||||
auto cp = *m_pos++;
|
||||
if (cp == '-')
|
||||
{
|
||||
ranges.push_back({ '-', '-' });
|
||||
|
@ -335,6 +335,13 @@ private:
|
|||
++m_pos;
|
||||
continue;
|
||||
}
|
||||
else // its just an escaped character
|
||||
{
|
||||
|
||||
if (++m_pos == m_regex.end())
|
||||
break;
|
||||
cp = *m_pos;
|
||||
}
|
||||
}
|
||||
|
||||
CharRange range = { cp, cp };
|
||||
|
@ -1223,6 +1230,12 @@ auto test_regex = UnitTest{[]{
|
|||
TestVM vm{R"(Foo(?i)f[oB]+)"};
|
||||
kak_assert(vm.exec("FooFOoBb"));
|
||||
}
|
||||
|
||||
{
|
||||
TestVM vm{R"([^\]]+)"};
|
||||
kak_assert(not vm.exec("a]c"));
|
||||
kak_assert(vm.exec("abc"));
|
||||
}
|
||||
}};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user