[CMake] CMake regexes: Case insensitive and whitespace matching

Roman Wüger roman.wueger at gmx.at
Mon May 8 17:15:53 EDT 2017


Hello Daniel,

I tried it also in various ways, but I think the Regex in Cmake is very limited. What has worked for me was to use try_run and implement a simple c++ application which uses C++11's <regex> and accept one or two command line arguments (~ 15 lines of code).

Hope it helps

Regards Roman

> Am 08.05.2017 um 15:19 schrieb Daniel Lueken <Daniel.Lueken at bmw-carit.de>:
> 
> Hi!
>  
> Is there any way to do case insensitive matching in string(REGEX … ?
> Also, is there a way to match whitespaces?
>  
> What I would like to do, speaking in Perl-like syntax, is something like
>  
> string(REGEX REPLACE “/something\s+/stuff/i” …
>  
> Not knowing how to do this, I am currently doing something along the lines of
>  
> string(REGEX REPLACE “[Ss][Oo][Mm][Ee][Tt][Hh][Ii][Nn][Gg][\\r\\n\\t ]+” …
>  
> which looks pretty wrong to me. Converting everything to upper or lower case is also not an option since parts of the input string in which I need to replace something are case sensitive.
>  
> Best regards
> Daniel Lueken
>  
> --
> BMW Car IT GmbH
> Daniel Lüken
> Spezialist Entwicklung
> Moosacher Straße 86
> 80809 München
> 
> Tel.: ­+49-89-189311-35
> Fax: +49-89-189311-20
> Mail: daniel.lueken at bmw-carit.de
> Web: http://www.bmw-carit.de
> -------------------------------------------------------------------------
> BMW Car IT GmbH
> Geschäftsführer: Kai-Uwe Balszuweit und Alexis Trolin
> Sitz und Registergericht: München HRB 134810
> -------------------------------------------------------------------------
>  
> -- 
> 
> Powered by www.kitware.com
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
> 
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170508/656e04c6/attachment.html>


More information about the CMake mailing list