The syntax used to describe these regular expressions is powerful, flexible, and unfortunately somewhat dialectal. A few major implementations of regular expressions available differ slightly in their details. Fortunately, these differences are not major, and we can typically move from one system to another without too much trouble.
PHP provides programmers with two regular expression processing engines. The first is called the Perl Compatible Regular Expressions (PCRE) extension and is modeled on the processor used in Perl, an extremely powerful language that has regular expressions tightly integrated into its programming model. The second flavor is called POSIX Extended Regular Expressions and is based on the standard for regular expressions defined by the POSIX 1003.2 standard.
Both extensions are enabled by default in PHP, and you can use them with a number of functions. However, this tutorial focuses entirely on the POSIX regular expressions for the following reasons:
PCRE is already extremely well documented in numerous places and has a remarkable amount of user support through the Perl community.
The POSIX regular expressions are multi-byte character set enabled in PHP, whereas the PCRE extension is not. Given that we are focusing our efforts largely on writing globalizable applications, we want to be sure foreign language characters can be properly processed.
This is not meant to be a judgment in favor of one regular expression engine over the other. There are a number of features in the PCRE engine that are not available in the POSIX one that many programmers find invaluable, and it can be faster in a number of situations. If your application does not require multi-byte character set support and you can be sure that you are dealing with input data that is in a certain code page, the Perl regular expressions might be appropriate for you.updated