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})
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})
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})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With