[cmake-developers] slow regex implementation in RegularExpression

Brad King brad.king at kitware.com
Wed Nov 23 12:48:49 EST 2011


On 11/23/2011 12:43 PM, Brad King wrote:
> On 11/23/2011 12:34 PM, Alexandru Ciobanu wrote:
>> The regex in question is:
>>     ^[^][:/*?]+\$
>> 
>> And it appears at this location in the ITK source tree:
>>     CMake/ExternalData.cmake:347
>> 
>> And the expression is correct, because you're allowed to have the ]
>> metacharacter inside a [^xyz] class if it comes immediately after ^.
> 
> Ironically I was the one that wrote that regex ;)
> 
>> TRE does not do it the same way, see
>> (http://laurikari.net/tre/documentation/regex-syntax/ the "Bracket
>> expressions" section):

Wait, that documentation does say the same thing:

 bracket-expression ::= "[" item+ "]"
                    |   "[^" item+ "]"

 "To include a literal ] in the list, make it either the first item"

That's exactly what this regex does.  It uses the second production
rule in the above grammar fragment and puts the ']' first after '^'.

-Brad



More information about the cmake-developers mailing list