Introduction to PCRE

The PCRE package contains Perl Compatible Regular Expression libraries. These are useful for implementing regular expression pattern matching using the same syntax and semantics as Perl 5.

Package Information

Additional Downloads

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/pcre

Installation of PCRE

Install PCRE by running the following commands:

patch -Np1 -i ../pcre-7.6-abi_breakage-1.patch &&
patch -Np1 -i ../pcre-7.6-security_fix-1.patch &&
./configure --prefix=/usr \
            --docdir=/usr/share/doc/pcre-7.6 \
            --enable-utf8 \
            --enable-pcregrep-libz \
            --enable-pcregrep-libbz2 &&

To test the results, issue: make check. Note: The third set of the tests cannot be run if the "fr_FR" locale is missing from the system.

Now, as the root user:

make install

If you reinstall Grep after installing PCRE, Grep will get linked against PCRE and may cause problems if /usr is a separate mount point. To avoid this, either pass the option --disable-perl-regexp when executing ./configure for Grep or move libpcre to /lib as follows.

mv -v /usr/lib/libpcre.so.* /lib/ &&
ln -v -sf ../../lib/libpcre.so.0 /usr/lib/libpcre.so

Command Explanations

--enable-utf8: This switch includes the code for handling UTF-8 character strings in the library.

--enable-unicode-properties: This switch enables Unicode properties support.

--enable-pcregrep-libz: This switch adds support to pcregrep to read .gz compressed files.

--enable-pcregrep-libbz2: This switch adds support to pcregrep to read .bz2 compressed files.


Installed Programs: pcregrep, pcretest, and pcre-config
Installed Libraries: libpcre.{so,a}, libpcrecpp.{so,a} and libpcreposix.{so,a}
Installed Directory: /usr/share/doc/pcre-7.6

Short Descriptions


is a grep that understands Perl compatible regular expressions.


can test a Perl compatible regular expression.


is used during the compile process of programs linking to the PCRE libraries.

Last updated on 2008-07-09 09:23:33 -0500