On 2012-12-13 13:44, David Cole wrote:
On Thu, Dec 13, 2012 at 1:38 PM, Matthew Woehlke wrote:Consider this line of CMake code: string(REGEX REPLACE "^([^.]*)(\..*)?$" "\1" BAR "${FOO}") It looks reasonable to me, and works fine on !Windows. However, on Windows, I get these errors: Syntax error in cmake code at <elided> when parsing string ^([^.]*)(\..*)?$ Invalid escape sequence \. Syntax error in cmake code at <elided> when parsing string \1 Invalid escape sequence \1For the replacement string, you need to use "\\1" -- the backslash in that context needs to be escaped to get through the CMake language, so that the regex engine sees "\1" internally...
I tried that, but then, as per...
Also, I can use "^([^.]*)([.].*)?$" instead to get around the first error, but then I get an error that the capture is empty. (It shouldn't be; "${FOO}" is non-empty and the pattern is guaranteed to have a non-ambiguous match for non-empty input.)
...I get this error. (More specifically, 'string sub-command REGEX, mode REPLACE regex "^([^.]*)(\..*)?$" matched an empty string.'.) Which isn't possible if the input is non-empty; as it is anchored on both ends, it must match the entire input, or not match at all.
-- Matthew -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
