Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake STRING REGEX REPLACE

Tags:

regex

cmake

I need to write regex in cmake lists to replace all ends of lines to spaces. I tried this, but it is incorrect

STRING(REGEX REPLACE "/\s+/g" " " output ${input})
like image 777
user3248822 Avatar asked Mar 25 '14 15:03

user3248822


2 Answers

The command expects a regular expression, but you're passing a sed argument in.

If you really want to replace all line-end characters with spaces, there's even no need for a regex at all. Just do this:

string(REPLACE "\n" " " output ${input})
like image 173
Angew is no longer proud of SO Avatar answered Nov 17 '22 10:11

Angew is no longer proud of SO


It is possible to do that by

string(REGEX REPLACE "[\r\n]*" " " output ${input})

Interestingly a relevant problem was to convert it into a list like the following,

string(STRIP ${input} stripppedinput)
string(REGEX REPLACE "[\r\n]*" ";" output ${strippedinput})
like image 2
KRoy Avatar answered Nov 17 '22 09:11

KRoy