Same thing with the other backslash, too. Double it up.
<div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Dec 13, 2012 at 1:44 PM, David Cole <span dir="ltr"><<a href="mailto:david.cole@kitware.com" target="_blank">david.cole@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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...<div class="HOEnZb">
<div class="h5"><div><br></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Dec 13, 2012 at 1:38 PM, Matthew Woehlke <span dir="ltr"><<a href="mailto:matthew.woehlke@kitware.com" target="_blank">matthew.woehlke@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Consider this line of CMake code:<br>
<br>
string(REGEX REPLACE "^([^.]*)(\..*)?$" "\1" BAR "${FOO}")<br>
<br>
It looks reasonable to me, and works fine on !Windows. However, on Windows, I get these errors:<br>
<br>
Syntax error in cmake code at <elided> when parsing string<br>
^([^.]*)(\..*)?$<br>
Invalid escape sequence \.<br>
<br>
Syntax error in cmake code at <elided> when parsing string<br>
\1<br>
Invalid escape sequence \1<br>
<br>
<br>
Is this expected? The documentation doesn't seem to explicitly mention replacement placeholders, but they are implicitly mentioned when talking about () capturing.<br>
<br>
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.)<br>


<br>
-- <br>
Matthew<br>
<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/<u></u>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/<u></u>CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers" target="_blank">http://public.kitware.com/cgi-<u></u>bin/mailman/listinfo/cmake-<u></u>developers</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>