View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014336CMakeCMakepublic2013-08-03 02:182016-06-10 14:31
Reporterirwin 
Assigned ToKitware Robot 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
PlatformLinuxOSOS VersionDebian Wheezy
Product VersionCMake 2.8.11.2 
Target VersionFixed in Version 
Summary0014336: REGEX REPLACE does not give correct results for a left anchor (^) combined with careted brackets
Description# 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).
Steps To ReproduceRun 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.
TagsNo tags attached.
Attached Files

 Relationships
related to 0015004closedKitware Robot string(REGEX REPLACE) doesn't correctly anchor regex with ^ for multiple matches 

  Notes
(0042342)
Kitware Robot (administrator)
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.

 Issue History
Date Modified Username Field Change
2013-08-03 02:18 irwin New Issue
2014-07-03 09:24 Brad King Relationship added related to 0015004
2016-06-10 14:29 Kitware Robot Note Added: 0042342
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team