While writing a command to invoke asciidoc, I thought I would use this
little regex replace to get the output file name:
string(REGEX REPLACE "([.][^.]+)?$" ".html" BAR "${FOO}")
However, CMake is throwing this error:
string sub-command REGEX, mode REPLACE regex "([.][^.]+)?$" matched an
empty string.
This doesn't seem right for two reasons:
1. The match (given an input 'foo.txt') should have been non-empty.
2. Even if the match is empty, the use of an anchor makes it definite
and non-ambiguous, so replacement should succeed.
For point 2, I get a similar error if the match is '^' or '$', both of
which I would have expected to be valid. (Silly perhaps if/when the
expression is known when writing the replace rule, as using a regex
replace is overkill for such a case, but still valid.)
For comparison, doing the replace with sed using the same expression
works as expected (i.e. { 'foo', 'foo.txt' } -> 'foo.html'). In
particular, while sed is understandably unhappy being asked to match and
replace '' (empty pattern), '^' and '$' are both valid.
Is this expected behavior, or should I file a bug?
(And yes, I'm now using get_filename_component, but still...)
--
Matthew
--
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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers