Skip to content

Instantly share code, notes, and snippets.

@toledorobia
Last active August 14, 2023 04:45
Show Gist options
  • Save toledorobia/25ef67b3793b2edac3eb to your computer and use it in GitHub Desktop.
Save toledorobia/25ef67b3793b2edac3eb to your computer and use it in GitHub Desktop.
MySQL - Validate email
SELECT *
FROM user
WHERE email NOT REGEXP '^[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9_\-]@[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]\.[a-zA-Z]{2,4}$'
@thureos
Copy link

thureos commented Jun 5, 2019

Saludos!

Gracias por este gist, pero creo que ya no soporta los nuevos TLD.

Que te parece este? Solo cambie la longitud del ultimo a +

SELECT * 
FROM user 
WHERE email NOT REGEXP '^[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9_\-]@[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]\.[a-zA-Z]+$'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment