PHP to determine the regular expression of e-mail address _php tutorial

Source: Internet
Author: User
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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.