php email郵箱正則
Jun 13, 2016 pm 12:25 PM
1.驗(yàn)證email:
復(fù)制代碼 代碼如下:
1. 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. ?>
國(guó)際域名格式如下:
域名由各國(guó)文字的特定字符集、英文字母、數(shù)字及“-”(即連字符或減號(hào))任意組合而成, 但開頭及結(jié)尾均不能含有“-”,“-”不能連續(xù)出現(xiàn) 。 域名中字母不分大小寫。域名最長(zhǎng)可達(dá)60個(gè)字節(jié)(包括后綴.com、.net、.org等)。
/^[a-z]([a-z0-9]*[-_]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[\.][a-z]{2,3}([\.][a-z]{2})?$/i;
/內(nèi)容/i 構(gòu)成一個(gè)不區(qū)分大小寫的正則表達(dá)式;
^ 匹配開始
$ 匹配結(jié)束
[a-z] E-Mail前綴必需是一個(gè)英文字母開頭
([a-z0-9]*[-_]?[a-z0-9]+)* 和_a_2、aaa11、_1_a_2匹配,和a1_、aaff_33a_、a__aa不匹配,如果是空字符,也是匹配的,*表示0個(gè)或者多個(gè)。
*表示0個(gè)或多個(gè)前面的字符.
[a-z0-9]* 匹配0個(gè)或多個(gè)英文字母或者數(shù)字
[-_]? 匹配0個(gè)或1“-”,因?yàn)椤?”不能連續(xù)出現(xiàn)
[a-z0-9]+ 匹配1個(gè)或多個(gè)英文字母或者數(shù)字,因?yàn)椤?”不能做為結(jié)尾
@ 必需有個(gè)有@
([a-z0-9]*[-_]?[a-z0-9]+)+ 見上面([a-z0-9]*[-_]?[a-z0-9]+)*解釋,但是不能為空,+表示一個(gè)或者為多個(gè)。
[\.] 將特殊字符(.)當(dāng)成普通字符
[a-z]{2,3} 匹配2個(gè)至3個(gè)英文字母,一般為com或者net等.
([\.][a-z]{2})? 匹配0個(gè)或者1個(gè)[\.][a-z]{2}(比如.cn等) 我不知道一般.com.cn最后部份是不是都是兩位的,如果不是請(qǐng)修改{2}為{起始字?jǐn)?shù),結(jié)束字?jǐn)?shù)}
完美E-Mail正則表達(dá)式,附詳細(xì)講解,請(qǐng)大家?guī)兔y(cè)試一下! 2.抽取字符串中的email:
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俺不是米vi地方就開iid郵件列表:fuyongjie@163.com 和hh@qq.com;.;;,fuyongjie.100@yahoo.com,fu-1999@sina.com";
$emailArr = getEmail($emailstr);
echo "
"; <br>print_r($emailArr); <br>echo "";
?>
打印如下:
Array
(
[0] => 9999@qq.com.cn
[1] => fuyongjie@163.com
[2] => hh@qq.com
[3] => fuyongjie.100@yahoo.com
[4] => fu-1999@sina.com
)
3.比較:第2里的正則里沒有了第1的^和$;

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

?In today's increasingly popular digital asset trading, it is particularly important to understand how to safely and effectively withdraw your digital assets. As a world-renowned digital asset trading platform, ok exchange provides convenient currency withdrawal services. This tutorial will analyze in detail the steps of withdrawing coins on the ok exchange, things to note, and some common questions and answers to help users complete asset transfer smoothly and ensure asset security. Whether you are using ok exchange for withdrawals for the first time or want to further understand the withdrawal process, this article will provide you with clear and practical guidance.

exit() is a function in PHP that is used to terminate script execution immediately. Common uses include: 1. Terminate the script in advance when an exception is detected, such as the file does not exist or verification fails; 2. Output intermediate results during debugging and stop execution; 3. Call exit() after redirecting in conjunction with header() to prevent subsequent code execution; In addition, exit() can accept string parameters as output content or integers as status code, and its alias is die().

To merge two PHP arrays and keep unique values, there are two main methods. 1. For index arrays or only deduplication, use array_merge and array_unique combinations: first merge array_merge($array1,$array2) and then use array_unique() to deduplicate them to finally get a new array containing all unique values; 2. For associative arrays and want to retain key-value pairs in the first array, use the operator: $result=$array1 $array2, which will ensure that the keys in the first array will not be overwritten by the second array. These two methods are applicable to different scenarios, depending on whether the key name is retained or only the focus is on

The rational use of semantic tags in HTML can improve page structure clarity, accessibility and SEO effects. 1. Used for independent content blocks, such as blog posts or comments, it must be self-contained; 2. Used for classification related content, usually including titles, and is suitable for different modules of the page; 3. Used for auxiliary information related to the main content but not core, such as sidebar recommendations or author profiles. In actual development, labels should be combined and other, avoid excessive nesting, keep the structure simple, and verify the rationality of the structure through developer tools.

The latest version of Binance is v2.102.5, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.

Dogecoin Trading App is a mobile trading platform specially designed for digital asset enthusiasts. It integrates market viewing, fast trading and asset management, and is committed to providing users with a safe, stable and convenient trading experience. Through this app, you can keep in mind the latest updates on digital assets such as Dogecoin anytime, anywhere. This article has compiled the latest official version of the app for you. Click the official download link provided in the article to easily obtain the latest version of the app.

The latest version of Binance is v2.102.5, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.

The latest version of Binance is v2.102.5, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.
