I believe that anyone who is familiar with PHP should know the following statement for eamil verification, but there is not much to understand:
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, 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.
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 one or more strings appear consecutively. "^" indicates that the next string must start, "$" indicates that the previous string must appear at the end;
"." Is also ".". Here "" is an escape character; "{2, 3}" indicates that the previous string can appear 2-3 times in a row. "()" Indicates that the contained content must appear in the target object at the same time. "[_. "0-9a-z-]" indicates that it is included in "_", ". ","-", letters from a to z, any characters in numbers from 0 to 9;
In this way, the regular expression can be translated as follows:
The following characters must start with (^), "_", and ". ","-", letters from a to z, numbers from 0 to 9 ([_. 0-9a-z-] "," the preceding character must appear at least once (+) ", @," the 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 "-", any letter from a to z, any number from 0 to 9, and finally in. end ([0-9a-z] [0-9a-z-] + .)) "," the preceding character appears at least once (+) ", and" letters from a to z appear 2-3 times, end with it ([a-z] {2, 3} $ )"
It's complicated, right? That's why people use regular expressions.