3

I am trying to validate string is alphabetic 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 string contains some other characters of different languages (ç, ë are used in albanian language)

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

Is there any general function or something which will fix this problem for any character set?

Sabri Aziri
  • 4,084
  • 5
  • 30
  • 45

1 Answers1

4

\p{L}\p{M}* matches any letter including diacritics (if any.)

user3942918
  • 25,539
  • 11
  • 55
  • 67
  • Great thing, thank you very much :) I tested it a little and look great, can you tell me what \p{L} means? – Sabri Aziri Aug 15 '14 at 15:40
  • This is a fantastic resource on this topic: [Unicode Regular Expressions](http://www.regular-expressions.info/unicode.html) – Parapluie May 10 '17 at 17:39