<?php
if (eregi ("^[_.0-9a-z-]+@" ([0-9a-z][0-9a-z-]+.) +[a-z]$ ", $email)) {
echo "Your e-mail through a preliminary check";
}
?>
In this sentence, the first is the application of a eregi function, this function is good understanding. If you look for a book, you can give an explanation:
Syntax: int ereg (string pattern, string string, array [regs]);
return value: Integer/array
This function parses string strings with the rule of pattern.
The value returned from the result is placed in the array parameter regs, Regs[0] content is the original string, string, Regs[1] is the first rule of the string, Regs[2] is the second rule of the string, and so on. If the parameter regs is omitted, it is simply a comparison, and the return value is true if found.
What is not well understood is the preceding regular expression: ^[_.0-9a-z-]+@ ([0-9a-z][0-9a-z-]+.) +[a-z]$
In this regular expression, "+" means that the preceding string has one or more occurrences; "^" means that the next string must appear at the beginning and "$" means that the previous string must appear at the end;
"." That is, ".", where "" is the escape character; "" indicates that the preceding string can occur 2-3 consecutive times. "()" means that the contained content must appear in the target object at the same time. "[_.0-9a-z-]" means any character contained in "_", ".", "-", letters from A to Z range, and numbers in the range from 0 to 9;
In this way, the regular expression can be translated like this:
"The following character must be at the beginning (^)", "the character must be contained in" _ ",". ","-", letters from A to Z range, numbers in the range from 0 to 9 ([_.0-9a-z-])," precedes this character at least once (+) ", @," The string starts with a character that is contained in a number from A to Z range, from 0 to 9, followed by at least one of the characters contained in "-", any letter from A to Z range, from 0 to 9 in any number, and finally ends with. ([0-9a-z][0-9a-z- ]+.) "," Before this character appears at least once (+) "," the letter from the A to the Z range appears 2-3 times and ends with it ([a-z]$) "
It's complicated, right, and that's why people use regular expressions.