CMP0186.rst 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. CMP0186
  2. -------
  3. .. versionadded:: 4.1
  4. Regular expressions match ``^`` at most once in repeated searches.
  5. This policy affects commands that perform multiple regular expression
  6. searches:
  7. * :command:`string(REGEX MATCHALL)`
  8. * :command:`string(REGEX REPLACE)`
  9. * :command:`list(TRANSFORM REPLACE)`
  10. and the generator expression :genex:`$<LIST:TRANSFORM,list,REPLACE>`.
  11. CMake 4.0 and below match the ``^`` anchor at the start of every
  12. successive search, leading to multiple matches:
  13. .. code-block:: cmake
  14. string(REGEX REPLACE "^a" "b" result "aaaa") # result="bbbb"
  15. string(REGEX MATCHALL "^a" result "aaaa") # result="a;a;a;a"
  16. CMake 4.1 and above prefer to match the ``^`` anchor at most once,
  17. at the start of the input string:
  18. .. code-block:: cmake
  19. string(REGEX REPLACE "^a" "b" result "aaaa") # result="abbb"
  20. string(REGEX MATCHALL "^a" result "aaaa") # result="a"
  21. This policy provides compatibility for projects that have not been updated.
  22. The ``OLD`` behavior for this policy is to match ``^`` multiple times,
  23. at the start of each search. The ``NEW`` behavior for this policy is
  24. to match ``^`` at most once, at the start of the input string.
  25. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 4.1
  26. .. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn
  27. .. include:: STANDARD_ADVICE.txt
  28. .. include:: DEPRECATED.txt