I’m trying to match strings like this one: {Изберете_цвят}
What I did is this regex, which according to regex101 should work: https://regex101.com/r/s3u7Op/1. But what’s weird is that on actual php 8.1.14 it doesn’t work:
var_dump(preg_match('/{([p{L}-_]+)}/', '{Изберете_цвят}', $matches)); // 0
If I remove the brackets it works:
var_dump(preg_match('/([p{L}-_]+)/', '{Изберете_цвят}', $matches)); // 1
If I put ascii characters instead of Cyrillic it also works:
var_dump(preg_match('/{([p{L}-_]+)}/', '{test}', $matches)); // 1
Tried also to escape the brackets, nothing changed.
What’s wrong here? It looks like the closing brackets got included in the catching group, buy why that doesn’t happen if there are only ascii chars? Also } doesn’t sound like a p{L} matches any kind of letter from any language to me…
—
Simpler example:
php > var_dump(preg_match('/{([p{L}]+)}/', '{бa}'));
int(0)
php > var_dump(preg_match('/{([p{L}]+)}/', '{aa}'));
int(1)
