[CMake] string(REGEX REPLACE …) syntax problem

Braden McDaniel braden at endoframe.com
Mon Apr 1 13:45:27 EDT 2013


On Mar 30, 2013, at 11:29 PM, David Cole <dlrdave at aol.com> wrote:

> REGEX REPLACE will replace "this" with "that" in the entire input string, everywhere it matches. If you want to limit it to just the one bit that matches inside the parenthesis, you have to match the entire string, too, so that it will also be replaced. In your example, the \\1 is being set to "Release" and the "/build Release" is being replaced with \\1 in the entire input string. So in effect, you erased the "/build " from in front of it. What you want is to erase the whole string, except for the "Release", right?
> 
> This should work:
> 
>> string(REGEX REPLACE "^.*/build ([A-Za-z]+).*$" "\\1" BUILD_CONFIG 
> ${FOO})
> 
> I just added "^.*" at the beginning, and ".*$" at the end, so it matches the entire input string.

Thank you... That makes sense, now that I think about it.

-- 
Braden McDaniel
braden at endoframe.com



More information about the CMake mailing list