preg_match() digits missing after \x
-
Environment:
Apache/2.4.65
PHP 8.4.15
WordPress 6.8.3On my development server, I found over 4MB of PHP warnings like this…
[24-Nov-2025 19:23:56 UTC] PHP Warning: preg_match(): Compilation failed: digits missing after \x or in \x{} or \o{} or \N{U+} at offset 30 in /var/www/wp-content/plugins/media-sync/includes/MediaSync.class.php on line 1103When I look at where that is happening I find this…
$is_ignored = preg_match('/(-scaled|[_-]\d+x\d+)|@[2-6]\x(?=\.[a-z]{3,4}$)|\.[a-z]{3,4}.webp/im', $file_name) == true;I suppose “\x” could be interpreted as a literal letter “x” or as the start of a hex code. It looks like you wanted it to be a literal letter x. You could get rid of the warning by just eliminating the slash in front of the x, just like you did in the first alternative, “\d+x\d+”
$is_ignored = preg_match('/(-scaled|[_-]\d+x\d+)|@[2-6]x(?=\.[a-z]{3,4}$)|\.[a-z]{3,4}.webp/im', $file_name) == true;Thanks for a really useful utility!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘preg_match() digits missing after \x’ is closed to new replies.