[CMake] Problem with regular expression

Sven Klomp mail at klomp.eu
Fri Jul 15 04:10:00 EDT 2011


Hi,

I'm using cmake 2.8.3 and have a problem using regular expressions:

STRING(REGEX REPLACE
      "^(Input:[0-9]+:)([^/].*)$"
      "_Start_\\1_Middle_\\2_End_"
      TESTVARIABLE
      "Input:1:filename1 \nInput:104:filename2 \n"
      )
MESSAGE("${TESTVARIABLE}")

The expected output is:
_Start_Input:1:_Middle_filename1_End_
_Start_Input:104:_Middle_filename2_End_

However, the actual output is:
_Start_Input:1:_Middle_filename1
Input:104:filename2
_End_

It seems that . matches also the newline, altough
http://www.cmake.org/cmake/help/syntax.html
says ist shouldn't!

How can I get the expected result?

Best regards
Sven


More information about the CMake mailing list