Skip to content

Instantly share code, notes, and snippets.

@ts0818
Created November 5, 2015 08:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ts0818/986f38a75d9a67b7bbcb to your computer and use it in GitHub Desktop.
PEAR::Mail_RFC822から抜き出したメールアドレスの正規表現による判定
<?php
function isValidInetAddress($data, $strict = false){
// 次の行は、表示改行されていますが実際は一行です
$regex = $strict ? ' /^([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i ' :
' /^([*+!.&#$|\'\\%\/0-9a-z^_`{ }=?~:-]+])@(([0-9a-z-]+\.)+[0-9a-z]{2,})$/i ';
if(preg_match($regex, trim($data),$matches)){
return array($matches[1], $matches[2]);
}else{
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment