PCRE Wrapper for Delphi 7
PCRE (Perl Compatible Regular Expressions) is a C library written by Philip Hazel of Cambridge University.
PCRE allows C and C++ programs to perform pattern matching using Perl-style regular expressions.
PCRE is written in ANSI C and is extremely portable (I have succesfully compiled and used PCRE under Windows 2000, Windows XP and several 32-bit and 64-bit Unix operating systems).
In order to make PCRE accessible from Delphi I have compiled PCRE as a DLL using MSVC.NET 2003. The C runtime has been statically linked to the DLL to make it completely self contained.
A few modification of the original C sources are needed before PCRE can be accessed by Delphi, mostly to allow access to exported variables that the Delphi linker is not able to import.
In agreement with PCRE licence the modified C sources of my custom version of the PCRE DLL are provided below.
The Delphi Wrapper Classes
Direct access to the PCRE API from a Delphi program is provided by the PCRE_DLL.pas import unit. Directly using the PCRE C API from Delphi is however not for the faint of heart.
For this reason together with the Delphi import unit I am also providing a set of Delphi classes and interfaces that provide an easy to use object-oriented wrapper around the PCRE API.
In addition to ease access to the underlying PCRE API, these wrapper classes also provide some functionality which is missing from the original PCRE API, like the possibilty to find all non-overlapping matches using a single method call, split a string using a regular expression, and search-replace using placeholder variables like in Perl.
The Delphi wrapper classes can be found in the PCRE.pas source file.
These zip files contain custom versions of PCRE 3.9, PCRE 4.5, PCRE 5.x and PCRE 6.x, and they are neither the original nor a complete distribution of PCRE.
To obtain the original PCRE distribution please go to the original PCRE FTP site at:
or visit the pcre.org web site at: