Skip to content

Instantly share code, notes, and snippets.

@hosseinm1997
Last active April 8, 2019 14:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hosseinm1997/7cecb6950e63d70bd9e33efeb2f9a86b to your computer and use it in GitHub Desktop.
Save hosseinm1997/7cecb6950e63d70bd9e33efeb2f9a86b to your computer and use it in GitHub Desktop.
اعتبار سنجی دقیق نام های ایرانی با کارکتر های فارسی بوسیله عبارات منظم _ Iranian names with only Farsi/Persian character validation with regular expression.
<?php
$fname = 'حسین';
if (!preg_match('/^([\x{0621}-\x{063A}\x{0641}-\x{064A}\x{064E}-\x{0651}\x{0654}-\x{0655}\x{06A9}\x{06CC}\x{FB8A}\x{067E}\x{0686}\x{06AF}\x{0698}\x{0670}\x{200c}\x{06c1}\x{06c2} ])+$/u', $fname))
{
echo "نام معتبر نیست!";
}
$fname = 'hossein';
if (!preg_match('/^([\x{0621}-\x{063A}\x{0641}-\x{064A}\x{064E}-\x{0651}\x{0654}-\x{0655}\x{06A9}\x{06CC}\x{FB8A}\x{067E}\x{0686}\x{06AF}\x{0698}\x{0670}\x{200c}\x{06c1}\x{06c2} ])+$/u', $fname))
{
echo "نام معتبر نیست!";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment