? Phpif (eregi (^ [_. 0-9a-z-] + @ ([0-9a-z] [0-9a-z-] + .) + [a-z] $, $ email) {echo your e-mail through a preliminary check ;}? In this sentence, an eregi function is first applied, which is quite understandable. If you look for a book, you can explain the syntax: intereg (stringpattern, st
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.
What I don't quite understand is the previous regular expression: ^ [_. 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, "$" indicates that the previous string must appear at the end;
"." 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;
In this way, the 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 preceding character 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.