Home Backend Development PHP Tutorial PHP email mailbox regular_PHP tutorial

PHP email mailbox regular_PHP tutorial

Jul 21, 2016 pm 03:48 PM
email php code copy regular Mail verify

1. Verify email:

Copy code The code is as follows:

1. < ?php
2. if ( ereg(“/^[a-z]([a-z0-9]*[-_.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a -z0-9]+)+[.][a-z]{2,3}([.][a-z]{2})?$/i; ”,$email)){
3. echo “Your email address is correct!";}
4. else{
5. echo "Please try again!";
6. }
7. ?>

The format of the international domain name is as follows:
The domain name is composed of any combination of specific character sets, English letters, numbers and "-" (i.e. hyphens or minus signs) in various countries, but it cannot contain "-" at the beginning or at the end. "-" cannot appear continuously. Letters in domain names are not case-sensitive. The domain name can be up to 60 bytes long (including suffixes .com, .net, .org, etc.).
/^[a-z]([a-z0-9]*[-_]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a- z0-9]+)+[.][a-z]{2,3}([.][a-z]{2})?$/i;
/content/i forms a case-insensitive regular expression Formula;
^ Match start
$ Match end
[a-z] E-Mail prefix must start with an English letter
([a-z0-9]*[-_]?[a- z0-9]+)* matches _a_2, aaa11, _1_a_2, but does not match a1_, aaff_33a_, a__aa. If it is a null character, it will also match. * means 0 or more.
* represents 0 or more previous characters.
[a-z0-9]* matches 0 or more English letters or numbers
[-_]? matches 0 or 1 "- ", because "-" cannot appear continuously
[a-z0-9]+ matches one or more English letters or numbers, because "-" cannot be the end
@ There must be @
([a-z0-9]*[-_]?[a-z0-9]+)+ see above ([a-z0-9]*[-_]?[a-z0-9]+) *Explanation, but it cannot be empty, + means one or more.
[.] Treat special characters (.) as ordinary characters
[a-z]{2,3} matches 2 to 3 English letters, usually com or net, etc.
([.][ a-z]{2})? Match 0 or 1 [.][a-z]{2} (such as .cn, etc.) I don’t know if the last part of .com.cn is usually two digits. If not, please Modify {2} to {starting word count, ending word count}
Perfect E-Mail regular expression, with detailed explanation, please help test it! 2. Extract email from the string:
<?php
function getEmail($str) {
$pattern = "/([a-z0-9]*[-_.]?[ a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[.][a-z]{2,3}([.][ a-z]{2})?/i";
preg_match_all($pattern,$str,$emailArr);
return $emailArr[0];
}
$emailstr = "9999@qq .com.cn If I am not from Mivi, I will open an iid mailing list: fuyongjie@163.com and hh@qq.com;, fuyongjie.100@yahoo.com, fu-1999@sina.com";
$emailArr = getEmail($emailstr);
echo "<pre>";
print_r($emailArr);
echo "</pre>";
?>
Print as follows:
Array
(
[0] => 9999@qq.com.cn
[1] => fuyongjie@163.com
[2] =&gt ; hh@qq.com
[3] => fuyongjie.100@yahoo.com
[4] => fu-1999@sina.com
)
3. Comparison: No. The regular expression in 2 no longer contains the first ^ and $;

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319666.htmlTechArticle1. Verify email: Copy the code as follows: 1. ?php 2. if (ereg(“/^[ a-z]([a-z0-9]*[-_.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+ )+[.][a-z]{2,3}([.][a-z]{2})?$/i; ”,$email)){ 3. e...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Deepseek official website entrance login tutorial Deepseek official website entrance login tutorial Feb 19, 2025 pm 04:24 PM

Deepseek official website entrance login tutorial

Sesame Open Door Official Website Sesame Open Door App Latest Entering Website Sesame Open Door Official Website Sesame Open Door App Latest Entering Website Feb 28, 2025 am 11:18 AM

Sesame Open Door Official Website Sesame Open Door App Latest Entering Website

Sesame Open Door Exchange Web Page Registration Link Gate Trading App Registration Website Latest Sesame Open Door Exchange Web Page Registration Link Gate Trading App Registration Website Latest Feb 28, 2025 am 11:06 AM

Sesame Open Door Exchange Web Page Registration Link Gate Trading App Registration Website Latest

gateio exchange web version registration portal gateio exchange web version registration portal Feb 20, 2025 pm 04:12 PM

gateio exchange web version registration portal

gate official website login address gate exchange official website login gate official website login address gate exchange official website login Feb 19, 2025 pm 03:09 PM

gate official website login address gate exchange official website login

Get Ouyi registration in 3 minutes Get Ouyi registration in 3 minutes Feb 19, 2025 pm 06:54 PM

Get Ouyi registration in 3 minutes

gate.io exchange official registration portal gate.io exchange official registration portal Feb 20, 2025 pm 04:27 PM

gate.io exchange official registration portal

gateio trading platform official website login gateio login portal gateio trading platform official website login gateio login portal Feb 21, 2025 pm 02:42 PM

gateio trading platform official website login gateio login portal

See all articles