Home > Backend Development > PHP Tutorial > PHP 正则表达式问题

PHP 正则表达式问题

WBOY
Release: 2016-06-06 20:36:51
Original
957 people have browsed it

  1. test@baidu.com
  2. test@baidu.com.cn
  3. test@baidu.a.com.cn

要用PHP正则判断是否合法的邮箱名称?

回复内容:

  1. test@baidu.com
  2. test@baidu.com.cn
  3. test@baidu.a.com.cn

要用PHP正则判断是否合法的邮箱名称?

php5.2版本的内置函数基本可以完美解决邮箱验证。
filter_var('bob@example.com', FILTER_VALIDATE_EMAIL);

呵呵,骚年,以为那么短的正则就能验证所有可能出现的邮箱格式吗!

最完备的Email地址正则表达式,长达6318个字符。

PHP 正则表达式问题

这个google一下就出来了吧

\w+([-+.]\w+)@\w+([-.]\w+).\w+([-.]\w+)*

针对php验证邮箱是否合法的问题,我个人建议可以参考PHPMailer的验证方式(class.phpmailer.php的validateAddress方法。)

Related labels:
php
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template