| The code is as follows: |
Copy code |
| Int preg_match (string pattern, string subject [, array matches [, int flags]) |
Search for the content that matches the regular expression given by pattern in the subject string.
If matches is provided, it is filled with the search results. $ Matches [0] will contain the text that matches the entire pattern, $ matches [1] will contain the text that matches the child pattern in the first captured bracket, and so on.
| The code is as follows: |
Copy code |
|
$ String = 'cgjp123 @ 163.com.cn ';
$ Pattren = "/^ [^ _] [w] + @ [w.] + [w] + [^ _] $ /";
If (preg_match ($ pattren, $ string, $ matches )){
Echo '<pre> ';
Print_r ($ matches );
Echo '</pre> ';
} Else {
Echo 'wrong email ';
} |
Check email integrity in php
| The code is as follows: |
Copy code |
<? Php
If (eregi ("^ [_. 0-9a-z-] + @ ([0-9a-z] [0-9a-z-] +.) + [a-z]? $ ",? $ Email )){
Echo "your e-mail via preliminary check www.111cn.net ";
}
?> |
^ ([A-Za-z0-9 _-] +) @ ([A-Za-z0-9 _-] +) (. [A-Za-z0-9 _-]) $/
Is to record the user name of the mail address, and the server address of the mail address (in the form of username@server.com and so on), in the end if you want to read the string recorded, you only need to use the "escape character + record order" for reading. For example, "1 second is equivalent to the first" [A-Za-z0-9 _-] + "," 2 second is equivalent to the second ([A-Za-z0-9 _-] +), "3 second is the third (. [A-Za-z0-9 _-]). But in php, "" is a special character and needs to be escaped, so "" should be written as "1 second" in the php expression 〃.
Other special symbols:
"|": Or symbol "|" is the same as or in php, but it is a "|", not the two "in php | "! It can be a character or another string, for example, "/abcd | dcba/" may match "abcd" or "dcba ".