[CMake] Problem with regular expression
Michael Hertling
mhertling at online.de
Sat Jul 30 00:10:46 EDT 2011
On 07/15/2011 10:10 AM, Sven Klomp wrote:
> 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!
Obviously, that's not true:
STRING(REGEX REPLACE "." "X" VAR "\n")
MESSAGE("VAR: ${VAR}")
yields:
VAR: X
> How can I get the expected result?
STRING(REGEX REPLACE
"(Input:[0-9]+:)([^/][^\n]*)"
"_Start_\\1_Middle_\\2_End_"
TESTVARIABLE
"Input:1:filename1 \nInput:104:filename2 \n"
)
Regards,
Michael
More information about the CMake
mailing list