Bug #80569 [Opn->Nab]: preg_match no empty (null or "") values in matches
| From: | requinix@php.net | Date: | Thu, 31 Dec 2020 20:18:28 +0000 |
| Subject: | Bug #80569 [Opn->Nab]: preg_match no empty (null or "") values in matches | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-231322@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80569&edit=1
ID: 80569
Updated by: requinix@php.net
Reported by: shardlow dot a at gmail dot com
Summary: preg_match no empty (null or "") values in matches
-Status: Open
+Status: Not a bug
Type: Bug
-Package: *Regular Expressions
+Package: PCRE related
Operating System: OSX Catalina
PHP Version: 7.4.13
Block user comment: N
Private report: N
New Comment:
Use PREG_UNMATCHED_AS_NULL.
Previous Comments:
------------------------------------------------------------------------
[2020-12-31 17:08:08] shardlow dot a at gmail dot com
Description:
------------
---
From manual page: https://php.net/function.preg-match
---
Test script:
---------------
//print_r($_GET);
//$value = '1:2.3';
//$value = '1:2';
$value = '2';
$matches = '';
preg_match('/^(\d{1,2}:)?(\d{1,2})(\.\d{1,2})?$/', $value, $matches);
echo '<br>';
echo '<br>';
print_r($matches);
echo '<br>';
echo phpversion();
Expected result:
----------------
Array ( [0] => 2 [1] => [2] => 2 [3]=>)
7.3.11
Actual result:
--------------
Array ( [0] => 2 [1] => [2] => 2 )
7.3.11
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80569&edit=1