當前位置:首頁 » 編程語言 » 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>

熱點內容
scratch少兒編程課程 發布:2025-04-16 17:11:44 瀏覽:642
榮耀x10從哪裡設置密碼 發布:2025-04-16 17:11:43 瀏覽:368
java從入門到精通視頻 發布:2025-04-16 17:11:43 瀏覽:89
php微信介面教程 發布:2025-04-16 17:07:30 瀏覽:311
android實現陰影 發布:2025-04-16 16:50:08 瀏覽:794
粉筆直播課緩存 發布:2025-04-16 16:31:21 瀏覽:346
機頂盒都有什麼配置 發布:2025-04-16 16:24:37 瀏覽:213
編寫手游反編譯都需要學習什麼 發布:2025-04-16 16:19:36 瀏覽:818
proteus編譯文件位置 發布:2025-04-16 16:18:44 瀏覽:368
土壓縮的本質 發布:2025-04-16 16:13:21 瀏覽:594