[CMake] regex first subfolder

Michael Wild themiwi at gmail.com
Mon Dec 26 06:40:52 EST 2011


On 12/26/2011 11:52 AM, Anton Sibilev wrote:
> Hello! Can you, please, help me with regex?
> 
> I have the string, for example, "aaa111/bbb222/ccc333".
> As the result of regex I want to get "aaa111", but I can't set proper
> expression..
> 
> string (REGEX REPLACE "^(.*/)?" "" folder ${folder}) ?
> 

string(REGEX REPLACE "^(/?[^/]+).*" "\\1" folder "${folder}")

Michael



More information about the CMake mailing list