PHP 8.0 no longer sets the PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL option, so is more strict about invalid regular expressions than PHP 7.3 and 7.4 (which set this option by default for backward compatibility). The UPGRADING file says:
- PCRE: . When passing invalid escape sequences they are no longer intepreted as literals. This behaviour previously required the X modifier - which is now ignored.
For example, '/\\?PHPUnit\\Framework\\TestCase/' is a "valid" regexp in PHP 7, but in PHP 8 it causes preg_match(): Compilation failed: PCRE2 does not support \F, \L, \l, \N{name}, \U, or \u. Because '\\' is a single backslash, actually 4 are needed to match a literal \ .