PHP 邮箱正则表达式

2220

PHP 邮箱正则表达式代码如下:

/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])*(\.([a-z0-9])([-a-z0-9_-])([a-z0-9])+)*$/i

实例演示:

<?php
$mail = 'runoob@runoob.com';  //邮箱地址$pattern = '/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])*(\.([a-z0-9])([-a-z0-9_-])([a-z0-9])+)*$/i';   //正则表达式preg_match($pattern, $mail, $matches);var_dump($matches);  //输出匹配结果?>