[php-src] Issue #8452: preg_match return wrong result
| From: | storm1er | Date: | Thu, 28 Apr 2022 08:40:56 +0000 |
| Subject: | [php-src] Issue #8452: preg_match return wrong result | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-241291@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8452
Author: storm1er
### Description
The following code:
```php
<?php
$code = "ABC";
$regex =
"/^[0-9a-zA-ZÀÁÂÃÄÅÑñÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝŸÇàáâãäåèéêëìíîïðòóôõöùúûüýÿç!\x22'#$&{}()[\]+,.;:=@\/|_
<>°-]+$/";
print_r(preg_match($regex, $code, $matches));
print_r($matches);
$code = "in§valid_code½";
$regex =
"/^[0-9a-zA-ZÀÁÂÃÄÅÑñÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝŸÇàáâãäåèéêëìíîïðòóôõöùúûüýÿç!\x22'#$&{}()[\]+,.;:=@\/|_
<>°-]+$/";
print_r(preg_match($regex, $code, $matches));
print_r($matches);
```
Resulted in this output:
```
1Array
(
[0] => ABC
)
1Array
(
[0] => in§valid_code½
)
```
But I expected this output instead:
```
1Array
(
[0] => ABC
)
0Array
(
)
```
### PHP Version
PHP 7.3.1+
### Operating System
_No response_