string: Allow zero-length matches in all REGEX subcommands

The semantics mimic other languages like Python, Java, JS, etc.
To advance past a zero-length match, the search algorithm first
tries to find a non-zero alternative branch. If that fails, it
force-advances by 1 character.

Fixes: #13790, #13792, #18690, #26629
This commit is contained in:
Nikita Nemkin
2025-02-14 22:13:19 +05:00
parent ca65fa9a7f
commit 8d455809b0
8 changed files with 181 additions and 46 deletions

View File

@@ -122,6 +122,9 @@ Search and Replace With Regular Expressions
string instead of the beginning of each repeated search.
See policy :policy:`CMP0186`.
Zero-length matches are allowed in ``MATCHALL`` and ``REPLACE``.
Previously, they triggered an error.
The replacement expression may contain references to subexpressions that
didn't match anything. Previously, such references triggered an error.