Alex Rivera | Logout

PHP and regexp to accept only Greek characters in form

Asked 2011-06-06T16:49:11.780
16

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 appreciated.

Edit
Report

1 Answer

-1

The modern Greek alphabet in UTF-8 is in the U+0386 - U+03CE range.

So the regex you need to accept Greek only characters is:

$regex_gr = '/^[\x{0386}-\x{03CE}]+$/u';

or (with spaces)

$regex_gr_with_spaces = '/^[\x{0386}-\x{03CE}\s]+$/u';
answered 2012-03-13T10:54:17.327

Your Answer