Description of common email verification statements

Source: Internet
Author: User
Anyone who trusts PHP should know the following statement for eamil verification, but there are only a few points to understand :? Phpif (eregi ("^ [_. 0-9a-z-] + @ ([0-9a-z] [0-9a-z-] + .) + [a-z] {2, 3} $ ", $ email) {echo" your E-Mail passed the preliminary check ";} anyone who trusts PHP should know the following statement for eamil verification, but only a few can understand it:
If (eregi ('^ [_. 0-9a-z-] @ ([0-9a-z] [0-9a-z-].) [a-z] {2, 3} $', $ email )){
Echo 'Your email has passed the preliminary check ';
}
?>
In this sentence, we first use an eregi function, which is quite understandable. If you look for a book, you can give a description:
Syntax: int ereg (string pattern, string, array [regs]);
Returned value: integer/array
This function uses pattern to parse and compare strings. The value returned by the comparison result is placed in the array parameter regs, the regs [0] content is the original string, regs [1] is the first regular string, regs [2] is the second regular string, and so on. If the regs parameter is omitted, only comparison is performed. if it is found, the return value is true.
What I don't quite understand is the previous regular expression: ^ [_. 0-9a-z-] @ ([0-9a-z] [0-9a-z-].) [a-z] {2, 3} $
In this regular expression, "" indicates that the previous string is continuously rendered one or more; "^" indicates that the next string must start, "$" indicates that the previous string must be rendered at the end; ". ", that is,". ", here" "is an escape character;" {2, 3} "indicates that the previous string can be sustained for 2-3 times. "()" Indicates that the content contained must be displayed in the target object at the same time. "[_. "0-9a-z-]" is represented in "_" and ". ","-", any character in the number range from a to z, from 0 to 9;
In this way, the regular expression can be translated as follows:
The following characters must start with (^), "_", and ". ","-", letters in the range from a to z, numbers in the range from 0 to 9 ([_. 0-9a-z-] "," The character above is displayed at least once () ", @," the string starts with a character from a letter in the range from a to z and a number in the range from 0 to 9, followed by at least one character in the "-", any letter in the range from a to z, any number in the range from 0 to 9, and finally. end ([0-9a-z] [0-9a-z-].) "," the preceding character is displayed at least once () ", and" Letters From a to z are displayed 2-3 times, end with it ([a-z] {2, 3} $ )"
It's very complicated, right. that's why people use regular expressions.

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.