How do PHP, preg_match and PERL actually interact

I have decided to bite the bullet and try and understand preg_match. As I understand so far, preg_match actually calls a PERL script. Is this correct and does PERL have to be installed on the server or is it or the required PERL functions included in some way with the PHP install. Also, I am told PHP uses a PCRE engine to parse the commands, I am also told that PCRE is one of 2 major parsers for PHP, the other being POSIX which is now deprecated. At this point I am totally lost and thinking that even my understanding of PHP is flawed. I thought I just installed PHP and then ran programs written in PHP. I appreciate I don’t really need to understand this to run preg_match, but I want to understand. So do I need to have PERL installed, are all PHP scripts parsed by PERL, what is PCRE? Can anybody enlighten me on this - thanks guys

I don’t know where you heard the preg_* calls PERL, it does not. PHP regex is PERL compatible, but that doesn’t mean that it is calling it.

Hi thanks

PHP has implemented quite a few regex functions which uses different parsing engines. There are two major parser in PHP. One called POSIX and the other PCRE or Perl Compatible Regular Expression.

The PHP function prefix for POSIX is ereg_ . Since the release of PHP 5.3 this engine is deprecated , but let’s have a look at the more optimal and faster PCRE engine.


PHP supports regular expressions through the use of the PCRE (Perl Compatible Regular Expressions) library which is enabled in almost all PHP installations.

OK I misunderstood, so this is a library included with PHP and the functions can be used by PHP and are also PERL compatible. So in most cases you install PHP and this library is included and enabled. Is that correct ?

Correct. I have never installed PERL for the purpose of using regular expressions.

Sponsor our Newsletter | Privacy Policy | Terms of Service