Hi I would like some help please if its possible.
I' m having a contact form in which the user submits his name. I use both in my javascript and php validation this regex:
/^[A-Z][A-Za-z.'\- ]+$/
for validatin the name, accepting only characters, whitespaces and - symbol. Although it works fine with english (latin characters), it doesn't work with greek. I want my regex to accept both english and greek characters, so when the user submits his name either in english either in greek it will "pass", if he enters any number or symbol like @,!,* etc (exept whitespaces, ' , -) fails.
Any help would be appreciated.
Help?use Regex that acceps both english and greek characters
Moderator: General Moderators
Re: Help?use Regex that acceps both english and greek charac
If php is compiled to accept the "u" modifier you can use the Letter property code which is rendered "\p{L}":
The "L" property code will accept letters in any language. If you just want only English and Greek letters, you need to find the Unicode range for Greek. Perhaps [a-z\x0370-\x1FFE]? See Wikipedia's info on Unicode ranges for Greek.
Also test it on your server to ensure the "u" modifier is enabled.
Code: Select all
preg_match('/^[\p{L}\.\'\- ]+$/u', $subject);Also test it on your server to ensure the "u" modifier is enabled.