How to fix PHP/PCRE unrecognised compile-time option bit(s) warning
We started to see the following warnings after upgrading to PHP 8.0.13. Despite only being warnings they cause the regex to fail and your application will probably error.
preg_match(): Compilation failed: unrecognised compile-time option bit(s) at offset 0
preg_replace(): Compilation failed: unrecognised compile-time option bit(s) at offset 0
PHP 8.1-rc5 and 8.0.13 includes a patch for a performance regression with PCRE functions, which caused a bug, and the fix requires a newer version of PCRE2 than we had installed on our system.
The solution is thankfully straightforward, upgrade your PCRE2 packages. For Ubuntu you can run this command, thanks to spideyfusion
sudo apt-get install --only-upgrade libpcre2-16-0 libpcre2-32-0 libpcre2-8-0 libpcre2-dev libpcre2-posix2