[Discuss] Regular expressions and Boolean logic
Peter Scott
Peter at PSDT.com
Mon Jul 16 15:11:38 PDT 2007
>On 2007-07-15 14:58-0700 Steven Kurylo wrote:
>
>On 7/15/07, D. S. <news.observer at gmail.com> wrote:
>If CMake uses pcre (perl compatable regular expressions), then you
>might look at a "zero-width negative look-ahead assertion", and see if
>it fits your case. It is described in the perl regular expressions
>(perlre) man page. Even if that worked, it would look messy. (But
>then again, how many REs are readable at first glance?)
>Maybe the boolean combination of regular expressions can be done in
>CMake itself?
>
>I don't you'll be able to find something very usable, unless CMake
>always you to negate the entire regular expression, or some kind of
>boolean logic.
>
>That being said, this regex will not match foo.pdf and bar.pdf, but
>will match everything else.
>
>^.(?!((?<=f)oo|(?<=b)ar)\.pdf$)
>
>Thanks, guys for the interesting RE information you have provided. That
>perlre man page takes regular expressions to a whole new level for me.
>However, from 'ldd cmake' it appears that cmake uses no external library for
>regular expressions. What they do internally with RE's is documented in the
>CMake FAQ at http://www.cmake.org/Wiki/CMake_FAQ. From that site, the
>following RE syntax seems to be supported by CMake:
>
>^ Matches at beginning of a line
>$ Matches at end of a line
>. Matches any single character
>[ ] Matches any character(s) inside the brackets
>[^ ] Matches any character(s) not inside the brackets
>- Matches any character in range on either side of a dash
>* Matches preceding pattern zero or more times
>+ Matches preceding pattern one or more times
>? Matches preceding pattern zero or once only
>() Saves a matched expression and uses it in a later match
>
>That list appears to have all the basics I am familiar with, but it does
>appear to be substantially more limited than the RE syntax available for
>pcre.
>
>Just in case that documentation is incomplete about the RE syntax that is
>supported by CMake, I have asked on the cmake list whether anybody can come
>up with a CMake RE that matches all .pdf files except foo.pdf and bar.pdf,
>but so far nobody has been able to do so.
Given that syntax subset I think it is all but provable that you can't
do what you want in a single regex. Well, I think it actually is
provable, I just don't know how to prove it :-)
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com/
http://www.perlmedic.com/
More information about the Discuss
mailing list