PHP and regexp to accept only Greek characters in form

前端 未结 7 1968
慢半拍i
慢半拍i 2020-12-11 16:07

I need a regular expression that accepts only Greek chars and spaces for a name field in my form (PHP). I\'ve tried several findings on the net but no luck. Any help will be

7条回答
  •  -上瘾入骨i
    2020-12-11 16:33

    To elaborate on leo pal's answer, an even more complete regex, which would accept even capital accented Greek characters, would be the following:

    /^[α-ωΑ-ΩίϊΐόάέύϋΰήώΊΪΌΆΈΎΫΉΏ\s]+$/
    

    With this, you get:

    • α-ω - lowercase letters
    • Α-Ω - uppercase letters
    • ίϊΐόάέύϋΰήώ - lowercase letters with all (modern) diacritics
    • ΊΪΌΆΈΎΫΉΏ - uppercase letters with all (modern) diacritics
    • \s - any whitespace character

    Note: The above does not take into account ancient Greek diacritics (ᾶ, ἀ, etc.).

提交回复
热议问题