Hi
I’ve got in some variable MYSTRING
a multiline string, for instance:
CMAKE_CXX_FLAGS_DEBUG: -g
CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O2 -g -DNDEBUG
CMAKE_CXX_FLAGS_RELEASE: -O3 -DNDEBUG
I’d like to get only
CMAKE_CXX_FLAGS_RELEASE: -O3 -DNDEBUG
My current approach is
string(REGEX MATCHALL "^.+$" MYSTRINGS ${MYSTRING})
list(GET MYSTRINGS -1 MYSTRING)
Though my regex seems to work (at least I tested on https://regex101.com/), in CMake I got only one match (MYSTRINGS has length 1) and MYSTRING
is the original one plus additional line feeds.
Can someone provide the right solution?
Thanks,
A.