On 11/28/2011 11:35 PM, Robert Dailey wrote:
> I haven't really seen a way to get a list of group matches in a regex. For
> example, string( REGEX MATCH ) only returns the whole string matched, not
> just what was in the capture groups. If I do this:
>
> (\\w+)\\,(\\w+)\\,(\\w+)
>
> and I match that regex against this string:
>
> hello,world,today
>
> I should get a list with:
>
> hello;world;today
>
> How can I do this?
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
PROJECT(REGEXREPLACE NONE)
STRING(REGEX REPLACE
"([A-Za-z0-9_]+),([A-Za-z0-9_]+),([A-Za-z0-9_]+)"
"\\1;\\2;\\3" RESULT "hello,world,today")
LIST(LENGTH RESULT n)
MESSAGE("n=${n}")
FOREACH(i IN LISTS RESULT)
MESSAGE("${i}")
ENDFOREACH()
Regards,
Michael
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake