當前位置:首頁 » 編程語言 » phpemail正則表達式

phpemail正則表達式

發布時間: 2025-03-07 20:34:21

『壹』 正則表達式如何驗證郵箱

1. php 郵箱驗證正則表達式:
preg_match("/^[0-9a-zA-Z]+@(([0-9a-zA-Z]+)[.])+[a-z]{2,4}$/i",$email );
如果需要更加完善、嚴格的驗證,修改這個正則表達式即可。

2. PHP 郵箱驗證正則表達式實例:
<?php
function isEmail($email){
if(preg_match("/^[0-9a-zA-Z]+@(([0-9a-zA-Z]+)[.])+[a-z]{2,4}$/i",$email )){
return '是郵箱';
} else{
return '不是郵箱';
}
}
?>

3. javascript(js) 郵箱驗證正則表達式:
myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,4}$/;
這個可以驗證 形如:[email protected] ,[email protected] 這槐襪種郵箱

4. Javascript(js) 郵箱驗證正則表達跡哪式實例:姿明碼
<script type="text/javascript">
function isEmail(val){
var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,4}$/;
if(!myreg.test(val))
return '不是郵箱';
return '是郵箱';
};
alert( isEmail('[email protected]') );
</script>

熱點內容
安卓泰拉瑞亞去哪裡買 發布:2025-07-18 20:01:05 瀏覽:694
flash編譯器 發布:2025-07-18 19:49:38 瀏覽:487
memcached源碼分析 發布:2025-07-18 19:22:42 瀏覽:866
android展示圖片 發布:2025-07-18 19:21:24 瀏覽:594
一台伺服器5個IP怎麼分配 發布:2025-07-18 19:12:34 瀏覽:862
貴陽分布式存儲行情 發布:2025-07-18 19:12:31 瀏覽:361
車場伺服器和工控機是如何連接的 發布:2025-07-18 19:10:19 瀏覽:938
計算機編程學什麼好 發布:2025-07-18 19:06:49 瀏覽:410
網吧用的伺服器是什麼伺服器 發布:2025-07-18 18:40:15 瀏覽:938
ftp命令使用 發布:2025-07-18 18:13:05 瀏覽:47