[Discuss] Regular expressions and Boolean logic

Alan W. Irwin irwin at beluga.phys.uvic.ca
Sun Jul 15 10:56:52 PDT 2007


I have the following problem:

CMake has the ability to make source distributions from all files in the
source tree excluding those specified with a regular expression for the
complete path+filename.

Let's suppose that I want to put foo.pdf and bar.pdf in the distribution, but
exclude all other *.pdf files.  One way is to list out all
the (numerous) specific *.pdf files in the source tree that should
be excluded, but that is a pain.

Is there a slick way to do it with regular expression syntax?  In particular
I need a regular expression that is the following Boolean combination of RE's:

/.*\.pdf$/ AND NOT /.*foo\.pdf$/ AND NOT /.*bar\.pdf$/

Can such a Boolean combination be done with regular expressions?  Basically
the infix operator "|" is the Boolean OR for regular expressions, but what
is the equivalent regular expression (if any) for the Boolean AND and
Boolean NOT?

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