Email validation with regular expression
برای چک کردن درستی کاراکترهای ایمیل در کد های PHP میتونید از کد زیر استفاده کنید :
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
echo "Invalid email";
}else{
echo "Valid Email";}
echo "Valid Email";}
اگه کاربر ایمیلشو اشتباه وارد کرده باشه پیام خطا بهش میده.
اینم از دستوالعملش :
\s -> this means an empty white space
^ -> this means start of a string
$ -> this means end of a string
. -> this means any character
(cat|mat) -> this means cat or mat
[0-9] -> this means all numbers from 0 to 9 inclusive
[a-z] -> this means all lowercase letters from a to z inclusive
[A-Z] -> this means all uppercase letters from A to Z inclusive
[^a-z] -> this means no occurrence of lowercase letters from a to z inclusive, the hat symbol (^) inside the sets denotes "not"
? -> this means zero or one of the proceeding characters
* -> this means zero or more characters
+ -> this means one or more characters
{3} -> this means exactly three characters
{3,} -> this means three or more characters
{3,6} -> this means 3 to 6 characters, it may be 3 or 4 or 5 or 6
^ -> this means start of a string
$ -> this means end of a string
. -> this means any character
(cat|mat) -> this means cat or mat
[0-9] -> this means all numbers from 0 to 9 inclusive
[a-z] -> this means all lowercase letters from a to z inclusive
[A-Z] -> this means all uppercase letters from A to Z inclusive
[^a-z] -> this means no occurrence of lowercase letters from a to z inclusive, the hat symbol (^) inside the sets denotes "not"
? -> this means zero or one of the proceeding characters
* -> this means zero or more characters
+ -> this means one or more characters
{3} -> this means exactly three characters
{3,} -> this means three or more characters
{3,6} -> this means 3 to 6 characters, it may be 3 or 4 or 5 or 6


0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home