<?php
$str = "Привeт, как делa?";
$pattern = "/[a-zA-Z]+/i";
echo preg_match($pattern, $str); // Outputs 1
$text = "Привeт, как делa? (жирные выделил замененные на латинские)";
function detect_unicode($text)
{
$out = "";
$flag = false;
for($i = 0; $i < strlen($text); ++$i)
{
if(mb_check_encoding($text[$i], 'UTF-8') && !preg_match('/([^a-zA-Zа-яА-Я])$/u', $text[$i]))
$out .= "<b>$text[$i]</b>";
else
{
$out .= $text[$i];
$flag = true;
}
}
return $flag ? $out : $text;
}
echo detect_unicode($text);