RegEx: Fix handling of unset/unknown capture groups

This commit is contained in:
Danil Alexeev 2024-11-29 18:49:19 +03:00
parent 893bbdfde8
commit 0339032969
No known key found for this signature in database
GPG key ID: 5A52F75A8679EC57
3 changed files with 49 additions and 19 deletions

View file

@ -145,6 +145,15 @@ TEST_CASE("[RegEx] Substitution") {
CHECK(re5.sub(s5, "cc", true, 0, 2) == "ccccaa");
CHECK(re5.sub(s5, "cc", true, 1, 3) == "acccca");
CHECK(re5.sub(s5, "", true, 0, 2) == "aa");
const String s6 = "property get_property set_property";
RegEx re6("(get_|set_)?property");
REQUIRE(re6.is_valid());
CHECK(re6.sub(s6, "$1new_property", true) == "new_property get_new_property set_new_property");
ERR_PRINT_OFF;
CHECK(re6.sub(s6, "$5new_property", true) == "new_property new_property new_property");
ERR_PRINT_ON;
}
TEST_CASE("[RegEx] Substitution with empty input and/or replacement") {