Bug #81198 [Opn]: preg_match doesn't work properly

From: Date: Wed, 23 Jun 2021 20:10:39 +0000
Subject: Bug #81198 [Opn]: preg_match doesn't work properly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234607@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81198&edit=1

 ID:                 81198
 Updated by:         danack@php.net
 Reported by:        advocat at gmail dot com
 Summary:            preg_match doesn't work properly
 Status:             Open
 Type:               Bug
 Package:            PCRE related
 Operating System:   OSX Big Sur
 PHP Version:        7.4.20
 Block user comment: N
 Private report:     N

 New Comment:

Please try disabling pcre.jit with ini_set("pcre.jit", "0")

possibly dupe of
https://bugs.php.net/bug.php?id=81185


Previous Comments:
------------------------------------------------------------------------
[2021-06-23 19:43:17] advocat at gmail dot com

Description:
------------
From manual page: https://php.net/function.preg-match

---

PHP 7.4.20 (cli) (built: Jun  4 2021 03:32:07) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.20, Copyright (c), by Zend Technologies

Test script:
---------------
$pattern  = "#/(?<moduleName>[^/]+)/layout/[^/]*\.xml$#i";
$filename =
"/var/www/project/vendor/magento/theme-frontend-blank/Magento_Theme/layout/default_head_blocks.xml";

var_dump(preg_match($pattern, $filename, $matches), $matches);

$pattern  = "#/([^/]+)/layout/[^/]*\.xml$#i";

var_dump(preg_match($pattern, $filename, $matches), $matches);

Expected result:
----------------
int(1)
array(3) {
  [0]=>
  string(45) "/Magento_Theme/layout/default_head_blocks.xml"
  ["moduleName"]=>
  string(13) "Magento_Theme"
  [1]=>
  string(13) "Magento_Theme"
}
int(1)
array(2) {
  [0]=>
  string(45) "/Magento_Theme/layout/default_head_blocks.xml"
  [1]=>
  string(13) "Magento_Theme"
}

Actual result:
--------------
int(0)
array(0) {
}
int(0)
array(0) {
}


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=81198&edit=1


Thread (5 messages)

« previous php.bugs (#234607) next »