Created
August 25, 2021 11:29
-
-
Save abdullahpazarbasi/3bd96a31f6c42fd181fd9a8b2f868d98 to your computer and use it in GitHub Desktop.
E-mail Regular Expression (Regex) Pattern PCRE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$sPattern = '^[^<>()[\]\\.,;:\s@"]+(?:\.[^<>()[\]\\.,;:\s@"]+)*@(?:xn--)?[a-zA-Z][a-zA-Z\d]*(?:-[a-zA-Z\d]+)*\.(?!local)[a-zA-Z]{2,32}(?:\.[a-zA-Z]{2})?$'; | |
// | |
$sSubject = 'john.doe@example.org'; | |
// | |
$aMatches = []; | |
if (preg_match($sPattern, $sSubject, $aMatches)) { | |
echo 'ok'; | |
} | |
else { | |
echo 'oops!'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment