regex: Match ^ at most once in repeated searches

When doing successive matches, track the input start and current search
start positions separately to prevent the `^` anchor from matching in
the middle of the string.  Add policy CMP0186 to provide compatibility.

Issue: #26629
Fixes: #16899
This commit is contained in:
Nikita Nemkin
2025-01-26 21:55:08 +05:00
parent 90625865e1
commit 5d039f3be3
26 changed files with 301 additions and 28 deletions
+5
View File
@@ -117,6 +117,11 @@ Search and Replace With Regular Expressions
two backslashes (``\\1``) are required in CMake code to get a backslash
through argument parsing.
.. versionchanged:: 4.1
The ``^`` anchor now matches only at the beginning of the input
string instead of the beginning of each repeated search.
See policy :policy:`CMP0186`.
.. _`Regex Specification`:
Regex Specification