Find occurences of unicode characters in string
Posted: Thu Oct 29, 2009 6:57 am
I need to prohibit filenames with everything but English characters and numbers but regexp and string function don't seem to work because they consider the Greek alphabet letters as part of the A-Z a-z sequence. Here's what I've tried:
if (strspn($str, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") != strlen($str))
{
echo 'invalid filename';
}
if (!preg_match("/^([-a-z0-9])+$/i", $str))
{
echo 'invalid filename';
}