Same thing with the other backslash, too. Double it up.
On Thu, Dec 13, 2012 at 1:44 PM, David Cole <[email protected]> wrote: > For 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... > > > > On Thu, Dec 13, 2012 at 1:38 PM, Matthew Woehlke < > [email protected]> 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 \1 >> >> >> Is this expected? The documentation doesn't seem to explicitly mention >> replacement placeholders, but they are implicitly mentioned when talking >> about () capturing. >> >> 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.) >> >> -- >> Matthew >> >> -- >> >> Powered by www.kitware.com >> >> Visit other Kitware open-source projects at http://www.kitware.com/** >> opensource/opensource.html<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<http://www.cmake.org/Wiki/CMake_FAQ> >> >> Follow this link to subscribe/unsubscribe: >> http://public.kitware.com/cgi-**bin/mailman/listinfo/cmake-**developers<http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers> >> > >
-- 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
