'email validation when i don't have @ or @ is the last character

I am trying to validate email using regex the problem is it fails to validate the email that doesn't have @ character or have have @ character by the end of the word like if i type abcd that would fail also abcd@ it would fail too. this is the regex i am using and i couldn't find anything that cover those cases the abcd and the abcd@

 let emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;


Solution 1:[1]

Try this regex snippet:

^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$

should invalidates cases like:

@gmail.com / [email protected]@

validates

[email protected]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1