MantisBT - CMake
View Issue Details
0014336CMakeCMakepublic2013-08-03 02:182016-06-10 14:31
irwin 
Kitware Robot 
normalminoralways
closedmoved 
LinuxDebian Wheezy
CMake 2.8.11.2 
 
0014336: REGEX REPLACE does not give correct results for a left anchor (^) combined with careted brackets
# Test code to show the issue.
set(filename "whatever")
string(REGEX REPLACE "(^[e])" "/\\1" CATALOG_filename "${filename}")
message(STATUS "filename=${filename}")
message(STATUS "CATALOG_filename=${CATALOG_filename}")
string(REGEX REPLACE "(^[^e])" "/\\1" CATALOG_filename "${filename}")
message(STATUS "filename=${filename}")
message(STATUS "CATALOG_filename=${CATALOG_filename}")

The first REGEX REPLACE gives a correct result (no match because of the anchor
so no replacement is done) while the second REGEX REPLACE produces an incorrect result (anchor ignored until the "e" is hit in whatever).
Run the above code using cmake -P. The results are

-- filename=whatever
-- CATALOG_filename=whatever
-- filename=whatever
-- CATALOG_filename=/w/h/a/tever

That last one should be

-- CATALOG_filename=/whatever

because the anchor should limit the match to just the first character (so long as that first character is not an "e" as in this case) so the "/" should be prepended only to the first character.
No tags attached.
related to 0015004closed Kitware Robot string(REGEX REPLACE) doesn't correctly anchor regex with ^ for multiple matches 
Issue History
2013-08-03 02:18irwinNew Issue
2014-07-03 09:24Brad KingRelationship addedrelated to 0015004
2016-06-10 14:29Kitware RobotNote Added: 0042342
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0042342)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.