[php-src] Issue #8653: preg_match flag ungreedy does not do what it should do in this special case
| From: | pud-micha | Date: | Mon, 30 May 2022 08:48:01 +0000 |
| Subject: | [php-src] Issue #8653: preg_match flag ungreedy does not do what it should do in this special case | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-241621@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8653
Author: pud-micha
### Description
The following code:
```php
$x = '<table></table><table> xyz </table>';
$p = '#<table[^>]*> xyz </table>#Umis';
preg_match_all($p, $x, $table);
print_r($table[0]);
$p = '#<table[^>]*>(.*xyz.*)</table>#Umis';
preg_match_all($p, $x, $table);
print_r($table[0]);
```
Resulted in this output:
```
Array
(
[0] => <table> xyz </table>
)
Array
(
[0] => <table></table><table> xyz </table>
)
```
But I expected this output instead:
```
Array
(
[0] => <table> xyz </table>
)
Array
(
[0] => <table> xyz </table>
)
```
### PHP Version
8.0.19
### Operating System
Windows