<? PHP
If (eregi ("^ [_. 0-9a-z-] + @ ([0-9a-z] [0-9a-z-] +.) + [A-Z] $", $ email )){
Echo "your email has passed the preliminary check ";
}
?>
In this sentence, an eregi function is first applied, which is quite understandable. If you look for a book, you can give an explanation:
Syntax: int ereg (string pattern, string, array [regs]);
Returned value: integer/Array
This function uses the Pattern Rule to parse and compare strings.
The value returned from 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.
the previous regular expression is ^ [_. 0-9a-z-] + @ ([0-9a-z] [0-9a-z-] + .) + [A-Z] $
In this regular expression, "+" indicates that one or more strings appear consecutively; "^" indicates that the next string must start with, and "$" indicates that the previous string must end with.
". "That is ". ", here" "is an escape character;" "indicates that the previous string can appear two or three times in a row. "()" Indicates that the contained content must appear in the target object at the same time. "[_. "0-9a-z-]" indicates that "_",". ","-", any character in the number range from A to Z, from 0 to 9;
then, this regular expression can be translated as follows:
"the following characters must start with (^)", "must be included in "_",". ","-", letters from A to Z, numbers from 0 to 9 ([_. 0-9a-z-]) "," the preceding character must appear at least once (+) ", @," This string starts with a character that contains 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 from A to Z, any number from 0 to 9, and finally in. end ([0-9a-z] [0-9a-z-] + .)) "," the character above appears at least once (+) "," the letter from A to Z appears 2-3 times, and ends with it ([A-Z] $) "
it's complicated, right. That's why people use regular expressions.