[php-src] Issue #8316: Unexpected behavior of preg_match

From: Date: Thu, 07 Apr 2022 12:49:35 +0000
Subject: [php-src] Issue #8316: Unexpected behavior of preg_match
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240744@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8316 Author: great-handsome ### Description The following code: ```php <?php $clean_text = "22ABCDE1ABCDE2ABCDE3ABCDE4ABCDE5ABCDESubtotalABCDE1ABCDE11111ABCDE111111ABCDE22222222222222222222222222222222222ABCDE111111111111111ABCDE211111111111111111111111ABCDE111111111111111111111111ABCDE11111111111111111111111111111ABCDE1111111111ABCDE11111111111111ABCDE11111111111111111111111111111111111111111111111111111"; if( preg_match( '/(.*)ABCDE(.*)ABCDE(.*)ABCDE(.*)ABCDE(.*)ABCDE(.*)ABCDESubtotal/',$clean_text, $data_d )) print_r($data_d); else echo 'NO'; ``` Resulted in this output: ``` NO ``` But I expected this output instead: ``` Array ( [0] => 22ABCDE1ABCDE2ABCDE3ABCDE4ABCDE5ABCDESubtotal [1] => 22 [2] => 1 [3] => 2 [4] => 3 [5] => 4 [6] => 5 ) ``` If I delete the last char from $clean_text ( or one char from 22222222222222222222222222222222222 ) , preg_match returns TRUE. I tried on PHP 7.4 and 8.1 , on 2 servers. ### PHP Version PHP 8.1 ### Operating System Ubuntu : Linux core 5.3.0-47-generic #39~18.04.1-Ubuntu SMP Mon Apr 6 17:04:32 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

« previous php.bugs (#240744) next »