<?php
if (eregi ("^[_.0-9a-z-]+@") ([0-9a-z][0-9a-z-]+.) +[a-z]$ ", $email)) {
echo" your e-mail through preliminary check ";
}
?>
In this sentence, the first is to apply a eregi function, this function is also good to understand. Find a book, and I'll give you an explanation.:
Syntax: int ereg (string pattern, string string, array [regs]);
return value: Integer/array
This function is P Attern the rule to parse the string.
The value returned by the result is placed in the array parameter regs, Regs[0] content is the original string string, Regs[1] is the first regular string, regs[2] is the second rule string, and so on. If the argument regs is omitted, the return value is true only if it is simply compared.
The
is not very well understood is the previous regular expression: ^[_.0-9a-z-]+@ ([0-9a-z][0-9a-z-]+.) +[a-z]$
In this regular expression, "+" means one or more consecutive occurrences of the preceding string; "^" 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 an escape character; "" indicates that the preceding string can appear 2-3 consecutive times. "()" means that the contained content must appear in the target object at the same time. "[_.0-9a-z-]" indicates that the "_" is included in the "_", ".", "-", letters from A to Z range, any character in numbers from 0 to 9;
Thus, this regular expression can be translated:
"The following character must be at the beginning (^ "," the character must be included in the _, ".", "-", letters from A to Z range, numbers from 0 to 9 ([_.0-9a-z-]) "," the preceding character appears at least once (+) ", @," The string consists of a letter in the range from A to Z, Starts with a character from a number in the range 0 through 9, followed by at least one of the characters contained in "-", any letter from A to Z range, from 0 to 9, and finally. 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.