mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-03 20:29:56 -06:00
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
20 lines
625 B
CMake
20 lines
625 B
CMake
cmake_policy(SET CMP0186 NEW)
|
|
|
|
function (output_results msg)
|
|
message("results from: ${msg}")
|
|
message("CMAKE_MATCH_0: -->${CMAKE_MATCH_0}<--")
|
|
message("CMAKE_MATCH_1: -->${CMAKE_MATCH_1}<--")
|
|
message("CMAKE_MATCH_2: -->${CMAKE_MATCH_2}<--")
|
|
message("CMAKE_MATCH_COUNT: -->${CMAKE_MATCH_COUNT}<--")
|
|
endfunction ()
|
|
|
|
set(haystack "Some::Scope")
|
|
|
|
string(REGEX MATCHALL "^([^:]+)(::)?" matches "${haystack}")
|
|
message("matches: ${matches}")
|
|
output_results("string(REGEX MATCHALL)")
|
|
|
|
string(REGEX REPLACE "^([^:]+)(::)?" "[\\1]" replace "${haystack}")
|
|
message("replace: ${replace}")
|
|
output_results("string(REGEX REPLACE)")
|