Runnign this snippet of PHP code:
preg_match("/^sito in (.*) \(([A-Z]{2})\)(.*)( CAP )?([0-9]{5})?$/U", "sito in Paternò (CT) Contrada Palazzolo, 28 CAP 95047", $matches);
var_dump(trim($matches[1]));
leads to this result:
string(8) "Paternò�"
(yes, there is a garbage character after the accented letter)
instead of the expected:
string(7) "Paternò"
How I can correctly extract words containing accented letters using preg_match?