search
Homephp教程php手册php 正则字符串中邮箱地址e-mail

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

Jun 13, 2016 am 11:18 AM
phpWho are youaddressstringarticleregularFirstObtainMailverify

 

如果你是验证邮箱第一个不错,如果你要获取文章或字符串中是否有邮箱地址,可以用第二个.
*/
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"


Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use