I have this string "2017-03-05-02-10-10_78205" and I want to match it with this pattern [0-9]{4}(-[0-9]{2}){5}_[0-9]+
but it doesn't work on CMake. See this example in CMake :
set(stuff "2017-03-05-02-10-10_78205")
if( "${stuff}" MATCHES "[0-9]{4}(-[0-9]{2}){5}_[0-9]+")
message("Hello")
endif()
CMake doesn't seem to support the syntax {n}
. Obviously, I solved my problem with that pattern [0-9-]+_[0-9]+
Nevertheless, I would like to know if I'm doing something wrong with the syntax {n}
. Is it supported by CMake ? If not, how to define a specific number of repetition with CMake ?
I'm using an old CMake version (2.8.11.2).
We can get around this problem by using shell commands and
execute_process
. For instance, withecho
andgrep
on linux :But we loose the cross-platform aspect of CMake.
According to CMake's documentation, it does not support the
{n}
syntax. Taken from that page:It does not seem to be a way to define a specific number of repetitions, rather than copying the expression, e.g.:
would become