1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 08:17:34 +00:00

LibRegex: Don't ignore empty alternatives in append_alternation()

Doing so would cause patterns like `(a|)` to not match the empty string.
This commit is contained in:
Ali Mohammad Pur 2021-10-29 16:21:13 +03:30 committed by Andreas Kling
parent 7ee409ef98
commit ac856cb965
2 changed files with 17 additions and 6 deletions

View file

@ -898,6 +898,7 @@ TEST_CASE(optimizer_atomic_groups)
// Alternative fuse
Tuple { "(abcfoo|abcbar|abcbaz).*x"sv, "abcbarx"sv, true },
Tuple { "(a|a)"sv, "a"sv, true },
Tuple { "(a|)"sv, ""sv, true }, // Ensure that empty alternatives are not outright removed
// ForkReplace shouldn't be applied where it would change the semantics
Tuple { "(1+)\\1"sv, "11"sv, true },
Tuple { "(1+)1"sv, "11"sv, true },