Quantcast

CMake regexes: Case insensitive and whitespace matching

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

CMake regexes: Case insensitive and whitespace matching

Daniel Lueken

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: [hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CMake regexes: Case insensitive and whitespace matching

Roman Wüger
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 <[hidden email]>:

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: [hidden email]
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

--

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CMake regexes: Case insensitive and whitespace matching

Daniel Lueken

Thanks!

 

I’ll take away the message that it is indeed not possible and I didn’t miss anything there. J

 

Regards

Daniel

 

--

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: [hidden email]
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
-------------------------------------------------------------------------

 

From: Roman Wüger [mailto:[hidden email]]
Sent: Monday, May 08, 2017 11:16 PM
To: Daniel Lueken <[hidden email]>
Cc: [hidden email]
Subject: Re: [CMake] CMake regexes: Case insensitive and whitespace matching

 

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 <[hidden email]>:

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: [hidden email]
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


--

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
Loading...