I'd like to capitalize the first letter of a string which could have special characters (that's the reason ucfirst is not valid here). I have next code:
$string = 'ésta';
$pattern = '/^([^a-z]*)([a-z])/i';
$callback_fn = 'process';
echo preg_replace_callback($pattern, $callback_fn, $string);
function process($matches){
return $matches[1].strtoupper($matches[2]);
}
which returns 'éSta' but 'Ésta' was expected... I think my problem is the pattern I'm using, but I have made different combinations (like $pattern = '/\pL/u') but I haven't found a good regex.