Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
SImple Regex for valid email with Javascript

regex valid js update 2021

const validEmail(str) => !/(\.{2}|-{2}|_{2})/.test(str) && /^[a-z0-9][a-z0-9-_\.]+@([a-z]|[a-z0-9]?[a-z0-9-]+[a-z0-9])\.[a-z0-9]{2,10}(?:\.[a-z]{2,10})?$/.test(str);

validEmail(''); //true
validEmail(''); //true
validEmail(''); //true
validEmail(''); // true (short domain)
validEmail(''); // true (short domain)
validEmail(''); // true (large extension)
validEmail(''); //false (not initial dot)
validEmail(''); //false (not dashes followed)
validEmail(''); //false (not dashes initial and end)

more use cases:

Copy link

victorcunya commented May 22, 2018

Muy buena tu validación para correos electrónicos, no tienes una para Python porfa 👍

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