string: Allow references to unmatched groups in REGEX REPLACE

References to unmatched groups will be replaced with empty strings.

Issue: #26629
Fixes: #19012
This commit is contained in:
Nikita Nemkin
2025-02-14 22:13:18 +05:00
parent 8845d33292
commit ca65fa9a7f
5 changed files with 13 additions and 5 deletions
+4
View File
@@ -116,6 +116,10 @@ elseif(testname STREQUAL regex_replace_index_too_small) # fail
elseif(testname STREQUAL regex_replace_index_too_large) # fail
string(REGEX REPLACE "^this (.*)$" "with \\1 \\2" v "this input")
elseif(testname STREQUAL regex_replace_index_no_match) # pass
string(REGEX REPLACE "^(this (.*)|(that .*))$" "with \\1 \\2 \\3" v "this input")
message(STATUS "v='${v}'")
elseif(testname STREQUAL compare_no_mode) # fail
string(COMPARE)