Last active
October 12, 2015 01:48
-
-
Save Stichoza/3952650 to your computer and use it in GitHub Desktop.
PHP E-mail and Username Validation
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 | |
function is_valid_email($s) { | |
return preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/', $s); | |
} | |
function is_valid_username($s) { | |
return preg_match('/^[A-Za-z0-9-_]+$/', $s); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment