While using preg_match_all function in php, i came across this issue of Compilation Failed.
preg_match_all('/<div>(?<product>.*)</li>/sU', $body, $matches)
I got the following error:
PHP Warning: preg_match_all(): Compilation failed: unrecognized character after (?< at offset 32 in …
This is probably you are having old version of pcre (for me it was 6.6-6) which needs to be updated to 8.0 or higher.
Default CentOS Repositories dont have the latest version, for this you can use Utter Ramblings yum repository
Steps to Add the Utter Ramblings yum repository
Create a file /etc/yum.repos.d/utterramblings.repo and paste the following:-
name=Jason’s Utter Ramblings Repo
sudo yum --enablerepo=utterramblings install pcre
Thats it, just in case you get some error messages as:-
Transaction Check Error:
file /usr/share/man/man1/pcretest.1.gz from install of pcre-8.02-1.jason.1.x86_64 conflicts with file from package pcre-6.6-6.el5_6.1.i386
then it might be because your system is 64 bit and you need to remove i386 version of lib, to fix it run
sudo yum remove pcre-6.6-6.el5_6.1.i386 sudo yum --enablerepo=utterramblings install pcre