Home > php教程 > php手册 > body text

php 正则字符串中邮箱地址e-mail

WBOY
Release: 2016-06-13 11:18:40
Original
1039 people have browsed it

 

如果你是验证邮箱第一个不错,如果你要获取文章或字符串中是否有邮箱地址,可以用第二个.
*/
function funcemail($str)//邮箱正则表达式
{
 return (preg_match('/^[_.0-9a-z-a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,4}$/',$str))?true:false;
}

/*
php教程 filter_sanitize_email 过滤器
filter_sanitize_email 过滤器删除字符串中所有非法的 e-mail 字符。

该过滤器允许所有的字符、数字以及 $-_.+!*'{}|^~[]`#%/?@&=。

*/

$var="some(one)@example.com";

var_dump(filter_var($var, filter_sanitize_email));

//string(19) "someone@example.com"


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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template