<div class="gmail_quote">On Thu, Jan 20, 2011 at 8:06 AM, Michael Wild <span dir="ltr">&lt;<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5">On 01/20/2011 02:01 PM, David Cole wrote:<br>
&gt; On Thu, Jan 20, 2011 at 7:39 AM, Michael Wild &lt;<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; On 01/20/2011 12:10 PM, SF Markus Elfring wrote:<br>
&gt;&gt;&gt;&gt; Thanks for your help to make CMake better,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Is the command variant &quot;string(REGEX REPLACE ...)&quot; completely documented?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Can multiple variables be specified that will receive the data from the<br>
&gt;&gt;&gt; evaluation of subexpressions in the passed regular expression?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Regards,<br>
&gt;&gt;&gt; Markus<br>
&gt;&gt;<br>
&gt;&gt; AFAIK no, but you can &quot;misuse&quot; if(&lt;string|varname&gt; MATCHES &lt;pattern&gt;)<br>
&gt;&gt; for this. It stores the groups in CMAKE_MATCH_&lt;n&gt; where &lt;n&gt; is {0..9}.<br>
&gt;&gt; Match 0 is always the whole match of &lt;pattern&gt; and match 1 is the<br>
&gt;&gt; contains the first group.<br>
&gt;&gt;<br>
&gt;&gt; Michael<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;&gt;<br>
&gt;&gt; Visit other Kitware open-source projects at<br>
&gt;&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;&gt;<br>
&gt;&gt; Please keep messages on-topic and check the CMake FAQ at:<br>
&gt;&gt; <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
&gt;&gt;<br>
&gt;&gt; Follow this link to subscribe/unsubscribe:<br>
&gt;&gt; <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; I think it&#39;s the case that the CMAKE_MATCH_* variables are set after *any*<br>
&gt; regex matching operation, be it from an &quot;if(... MATCHES ...)&quot; or a<br>
&gt; &quot;string(REGEX&quot; or &quot;string(MATCH&quot; command. Let us know if you find that not<br>
&gt; to be true.<br>
&gt;<br>
&gt; From the bottom of (<br>
&gt; <a href="http://cmake.org/cmake/help/cmake-2-8-docs.html#command:string" target="_blank">http://cmake.org/cmake/help/cmake-2-8-docs.html#command:string</a> ) :<br>
&gt;<br>
&gt;   () Saves a matched subexpression, which can be referenced<br>
&gt;      in the REGEX REPLACE operation. Additionally it is saved<br>
&gt;      by all regular expression-related commands, including<br>
&gt;      e.g. if( MATCHES ), in the variables CMAKE_MATCH_(0..9).<br>
&gt;<br>
&gt;<br>
&gt; HTH,<br>
&gt; David<br>
&gt;<br>
<br>
</div></div>Ah, yes. I keep forgetting. Might I propose that the documentation about<br>
regular expressions be extracted into its own section and then be<br>
referenced from all commands that have a REGEX mode? Because,<br>
confusingly, the only documentation about regular expression is at the<br>
end of the string(REGEX REPLACE) command, but then uses if(... MATCHES<br>
...) as an example. For the reader of the if( MATCHES ) documentation,<br>
this isn&#39;t very discoverable, it doesn&#39;t even refer him to the<br>
string(REGEX REPLACE) command.<br>
<font color="#888888"><br>
<br>
Michael<br>
</font></blockquote></div><br><br>Me too. I had to go searching for &quot;CMAKE_MATCH_&quot; because I knew it was stated somewhere. Much to my surprise, there was only a single &quot;CMAKE_MATCH&quot; on our whole documentation page. It would make sense to document the variables CMAKE_MATCH_0 and friends explicitly. And cross-referencing left, right, north and south would also be good.<br>
<br>You can propose all you want. I keep getting distracted by the &quot;real bugs&quot; on my plate...<br><br>:-)<br><br>