[Discuss] Regular expressions and Boolean logic
Alan W. Irwin
irwin at beluga.phys.uvic.ca
Mon Jul 16 13:09:31 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.
Alan
__________________________
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________
Linux-powered Science
__________________________
More information about the Discuss
mailing list