Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
*
* Valida un email usando expresiones regulares.
* Devuelve true si es correcto o false en caso contrario
*
* @param string $str la dirección a validar
* @return boolean
*
*/
function is_valid_email($str)
{
$matches = null;
return (1 === preg_match('/^[A-z0-9\\._-]+@[A-z0-9][A-z0-9-]*(\\.[A-z0-9_-]+)*\\.([A-z]{2,6})$/', $str, $matches));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.