<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-im"></span>You should really change it for beauty of the code. </blockquote><div> </div><div>Okay, on it. Thanks for the help.</div><div><br></div><div>Prasun<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 11 Jun 2020 at 10:13, Thomas Baumgart <<a href="mailto:thb@net-bembel.de">thb@net-bembel.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Donnerstag, 11. Juni 2020 05:04:20 CEST Prasun Kumar wrote:<br>
<br>
> I did it using this:<br>
> string(REGEX MATCH "Bankleitzahlendateien - gültig vom ([^ ]*)" FILE_DATE<br>
>  "${DATA}")<br>
>     if(FILE_DATE)<br>
>         string(REPLACE "Bankleitzahlendateien - gültig vom " "" FILE_DATE<br>
> "${FILE_DATE}")<br>
>     endif()<br>
<br>
That indeed looks a bit awkward. Thinking about it, I would use this<br>
<br>
  string(REGEX MATCH "([0-9\.]+)" FILE_DATE ${FILE_DATA})<br>
<br>
to extract the date from the filename. If you really want to make sure<br>
the filename matches the whole pattern, you could use this two step approach:<br>
<br>
  string(REGEX MATCH "Bankleitzahlendateien - gültig vom ([^ ]*)" FILE_DATE ${DATA})<br>
  string(REGEX MATCH "([0-9\.]+)" FILE_DATE ${FILE_DATE})<br>
<br>
The first regex makes sure that the full pattern matches and the<br>
second extracts the date from it.<br>
<br>
<br>
> But anyway, thanks. It will help me next time.<br>
<br>
You should really change it for beauty of the code. <br>
<br>
<br>
> BTW is this feature mentioned somewhere in the CMake documentation?<br>
<br>
>From <a href="https://cmake.org/cmake/help/v3.0/command/string.html" rel="noreferrer" target="_blank">https://cmake.org/cmake/help/v3.0/command/string.html</a> <br>
<br>
()        Saves a matched subexpression, which can be referenced<br>
          in the REGEX REPLACE operation. Additionally it is saved<br>
          by all regular expression-related commands, including<br>
          e.g. if( MATCHES ), in the variables CMAKE_MATCH_(0..9).<br>
<br>
-- <br>
<br>
Regards<br>
<br>
Thomas Baumgart<br>
<br>
<a href="https://www.signal.org/" rel="noreferrer" target="_blank">https://www.signal.org/</a>       Signal, the better WhatsApp<br>
-------------------------------------------------------------<br>
Linux & Open Source Software - aaah, the sweet smell of 'Free'dom<br>
-------------------------------------------------------------<br>
</blockquote></div>