Php checks if a string is alphabetic including cyrillic, greek or any unicode letter

I'm trying to validate a string is an alphabet including multiple character sets:

function is_string($str){
    return preg_match("/^[a-zA-Z\p{Cyrillic}\p{Cyrillic}]+$/u", $str) ? TRUE : FALSE;
}

      

but it fails if the string contains some other characters of different languages ​​(ç, ë are used in Albanian)

is_string('ç');//false
is_string('ë');//false

      

Is there any general feature or something that will fix this issue for any character set?

+3


source to share


1 answer


\p{L}\p{M}*

matches any letter, including diacritics (if any.)



+4


source







All Articles