In PHP we often use regular expressions to verify that the user entered the information is not the e-mail address, let me introduce you to determine the e-mail address of the regular expression of the detailed
Judge a regular expression of a message, step-by-step to explain what it means
The code is as follows |
Copy Code |
^ (w+ ((-w+) | (. w+)) +w+ ((-w+) | (. w+)) *@[a-za-z0-9]+ ((. | -) [a-za-z0-9]+] *. [a-za-z0-9]+$ |
^ Match string header
(w+ (-w+) | (. w+)) 1: This matches the string laidfj456, Sfi-lsoke, fe.23i, and so on
+ Match Plus
w+ ((-w+) | (. w+)) * Same as 1
Match
[a-za-z0-9]+ 2: A string of uppercase and lowercase letters and numbers, equivalent to w+
((.| -) [a-za-z0-9]+] * matches 0 or more by "." Or "-" begins with a string, such as. OEIU234MJ,-oiwuer4
. Match "."
[A-za-z0-9]+ with 2
$ matches the string's tail
Instance
The code is as follows |
Copy Code |
/** * Regular Expressions for messages @author: Lijianghai */ function Isemail ($input = null) {//username: composed of numbers, letters and slides; $email = $input; /* error using Preg_ereg (): Because the second parameter needs to be an array * IF (Preg_grep ("^[a-za-z][a-za-z0-9_]{3,19}@[0-9a-za-z]{1,10} (.) (com|cn|net|com.cn) $ ", Array ($input))) { echo $email. ' is a qualified email address '; }else { echo $email. ' Format error '; } */ if (Ereg ("^[a-za-z][a-za-z0-9_]{3,9}@[0-9a-za-z]{1,10} (.) (com|cn|com.cn|net) $ ", $email)) { echo $email. " Conforming to the format specification "; } Else { echo $email. ' Format error '; } } $email = ""; Isemail ($email); ?> |
http://www.bkjia.com/PHPjc/631271.html www.bkjia.com true http://www.bkjia.com/PHPjc/631271.html techarticle in PHP We often use the regular expression to verify that the user entered the information is not the e-mail address, the following I will introduce you to determine the e-mail address of the regular expression of the detailed evaluation of the mail ...