Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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