Code Snippets
Login
Regex email test
Email verification function with Regex explanation
Label
function isValidEmail(mail) { const email = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; /* reminder to self: / -> / = here is Regex ^ = start of string [] = character set (\s = space) ^ in [] = must not contain + = string must contain So, above test is 'string must not contain space or @ before the @ nor should it have space or @ before the . nor should it have space or @ after the .' */ return email.test(mail); }
Copy to clipboard
Copied!
©
Leerlandais 2024