Issue: https://github.com/php/php-src/issues/10038
Author: cedric-anne
### Description
The following code:
```php
<?php
$str = "Test\u{00a0}string";
$patterns = [
'\xa0',
'.+\xa0',
'(Test)?\xa0',
'Test\xa0',
'\xa0string',
];
foreach (['', 'u'] as $modifiers) {
echo empty($modifiers)
? 'Results for patterns without modifiers:'
: sprintf('Results for patterns with "%s" modifiers:', $modifiers);
echo PHP_EOL;
foreach ($patterns as $pattern) {
$pattern = "/{$pattern}/{$modifiers}";
printf(
' - Pattern "%s" %s',
$pattern,
preg_match($pattern, $str) === 1 ? 'matches' : 'does not match'
);
echo PHP_EOL;
}
echo PHP_EOL;
}
```
Resulted in this output:
```
Results for patterns without modifiers:
- Pattern "/\xa0/" matches
- Pattern "/.+\xa0/" matches
- Pattern "/(Test)?\xa0/" matches
- Pattern "/Test\xa0/" does not match
- Pattern "/\xa0string/" matches
Results for patterns with "u" modifiers:
- Pattern "/\xa0/u" matches
- Pattern "/.+\xa0/u" matches
- Pattern "/(Test)?\xa0/u" matches
- Pattern "/Test\xa0/u" matches
- Pattern "/\xa0string/u" matches
```
But I expected this output instead:
```
Results for patterns without modifiers:
- Pattern "/\xa0/" matches
- Pattern "/.+\xa0/" matches
- Pattern "/(Test)?\xa0/" matches
- Pattern "/Test\xa0/" matches
- Pattern "/\xa0string/" matches
Results for patterns with "u" modifiers:
- Pattern "/\xa0/u" matches
- Pattern "/.+\xa0/u" matches
- Pattern "/(Test)?\xa0/u" matches
- Pattern "/Test\xa0/u" matches
- Pattern "/\xa0string/u" matches
```
To be more precise, i was expecting preg_match calls would return the same result for
all listed patterns when the u modifier is missing. I would understand that none match,
but it is a bit hard to understand why only one of them is not matching.
### PHP Version
PHP 8.1.13 (cli) (built: Nov 29 2022 02:48:37) (NTS)
### Operating System
Debian Buster docker container hosted by Ubuntu 22.04