[CMake] matching a literal '+' in a regular expression

James Bigler bigler at cs.utah.edu
Fri May 11 15:20:35 EDT 2007


Ah, yes.  I forgot about that.  That worked!

Thanks,
James

David Cole wrote:
> Try "g\\+\\+.*$" -- the backslashes themselves need to be escaped inside a
> CMake string first... (Then the regex parser will see it as your original
> "g\+\+.*$")
> 
> The error is because CMake doesn't recognize "\+" as a string escape
> sequence.
> 
> On 5/11/07, James Bigler <bigler at cs.utah.edu> wrote:
>>
>> How do I match a literal '+' in a regular expression?
>>
>> This matches in grep (because it doesn't treat '+' as a special
>> character), but CMake says it can't compile it (for good reason if '+'
>> is a special character).
>>
>> "g++.*$"
>>
>> I tried escaping the '+', but that didn't work either:
>>
>> "g\+\+.*$"
>>
>> syntax error, unexpected cal_ERROR, expecting $end (3), when parsing
>> string "g\+\+.*$"
>>
>> I'm trying to match string g++, g++-4.0 etc.
>>
>> Thanks,
>> James
>> _______________________________________________
>> CMake mailing list
>> CMake at cmake.org
>> http://www.cmake.org/mailman/listinfo/cmake
>>
> 


More information about the CMake mailing list