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

David Cole david.cole at kitware.com
Fri May 11 15:15:06 EDT 2007


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20070511/313f77b9/attachment.html


More information about the CMake mailing list