PHP and regexp to accept only Greek characters in form

前端 未结 7 1979
慢半拍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条回答
  •  臣服心动
    2020-12-11 16:45

    The other answers here didn't work for me. Greek Unicode characters are included in the following two blocks

    • Greek and Coptic U+0370 to U+03FF (normal Greek letters)
    • Greek Extended U+1F00 to U+1FFF (Greek letters with diacritics)

    The following regex matches whole Greek words:

    [\u0370-\u03ff\u1f00-\u1fff]+
    

    I will let the reader translate that to whichever programming language format they may be using.

提交回复
热议问题