Title: PHP Warning: preg_match(): Compilation failed
Last modified: February 24, 2019

---

# PHP Warning: preg_match(): Compilation failed

 *  [Julie Moynat](https://wordpress.org/support/users/juliemoynat/)
 * (@juliemoynat)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/php-warning-preg_match-compilation-failed/)
 * Hi,
 * I have this PHP Warning looping in my log files, each day (I think it’s since
   7.3 version but I’m not really sure):
 * PHP Warning: preg_match(): Compilation failed: invalid range in character class
   at offset 29 in /wp-content/plugins/better-wp-security/core/modules/file-change/
   lib/package-factory.php on line 96
 * Do you know what the problem is?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [nlpro](https://wordpress.org/support/users/nlpro/)
 * (@nlpro)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/php-warning-preg_match-compilation-failed/#post-11242570)
 * It’s probably a php 7.3 incompatibility issue with the plugin.
 * In php 7.3 PCRE (Perl Compatible Regular Expressions) has been updated to v2.
 * PCRE is a library that PHP uses for dealing with Regular Expressions.
 * PCRE2 is more strict in the pattern validations, so after php upgrade, some of
   the patterns that used to work may not compile anymore.
 * Now there isn’t a regular expression pattern visible on line 96 in the package-
   factory.php file … but there is a regular expression being executed:
 *     ```
       95	if ( '@' === $search_path[0] ) {
       96		if ( ! preg_match( $search_path, $file ) ) {
       ```
   
 * I’ve included the previous line as well in the code above, because it tells us
   what regex pattern to look for. One that starts with a @.
    There is only one 
   match in the entire package-factory.php file:
 * `32 $core_files = '@' . preg_quote( ABSPATH, '@' ) . '[\w-_]+\.@';`
 * It’s the ‘[\w-_]+\.@’ part at the end where the problem is. The hyphen needs 
   to be escaped. So it should be ‘[\w\-_]+\.@’.
 * Make a backup copy of the current package-factory.php file. Make the edit as 
   described above and then see whether the warnings in the log disappear.
 * To prevent any confusion, I’m not iThemes.
    -  This reply was modified 7 years, 3 months ago by [nlpro](https://wordpress.org/support/users/nlpro/).
 *  Thread Starter [Julie Moynat](https://wordpress.org/support/users/juliemoynat/)
 * (@juliemoynat)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/php-warning-preg_match-compilation-failed/#post-11269089)
 * Thank you for your answer!
 * You were right, I have PHP 7.3 so I’ve tested your fix and it seems that it’s
   working. File change warnings are now working better.
 * I’ve also noticed another PHP Warning but I don’t know if it’s a PHP 7.3 incompatibility
   as well:
 * PHP Warning: printf(): Too few arguments in /wp-content/plugins/better-wp-security/
   core/modules/malware/settings-page.php on line 52
 * I hope iThemes will fix these issues soon.
 *  [nlpro](https://wordpress.org/support/users/nlpro/)
 * (@nlpro)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/php-warning-preg_match-compilation-failed/#post-11269291)
 * Ok, great. Thanks for your confirmation. Naturally iThemes will need to fix this
   bug in a future release. It may take a while since iThemes does not monitor this
   forum.
 * As to the other warning, you are probably using the WordPress Dashboard in a 
   non English language (French I guess). So it’s basically a known translation 
   issue (in the French translation of the iTSec plugin). So it’s not a bug in the
   plugin code.
 * Since it’s a different issue please create a seperate topic.
 * Oh (almost forgot) I guess this topic can be set to Resolved 😉
    -  This reply was modified 7 years, 3 months ago by [nlpro](https://wordpress.org/support/users/nlpro/).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘PHP Warning: preg_match(): Compilation failed’ is closed to new replies.

 * ![](https://ps.w.org/better-wp-security/assets/icon.svg?rev=3529351)
 * [Kadence Security – Password, Two Factor Authentication, and Brute Force Protection](https://wordpress.org/plugins/better-wp-security/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/better-wp-security/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/better-wp-security/)
 * [Active Topics](https://wordpress.org/support/plugin/better-wp-security/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/better-wp-security/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/better-wp-security/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [nlpro](https://wordpress.org/support/users/nlpro/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/php-warning-preg_match-compilation-failed/#post-11269291)
 * Status: not resolved