DEV Community

Suhana
Suhana

Posted on

What is a regex for a email?

My email can also contain special characters including @,&,-,_,:,(),|
I have wrote



But it doesn't seem efficient. Any suggestions?
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
polterguy profile image
Thomas Hansen

Email regex isn't even possible in theory to implement 100%. You'll have to parse the thing. Read the RFC ... 😟

Collapse
 
phlash profile image
Phil Ashby

There are many examples available on the web... this is typical:
stackoverflow.com/questions/139924...

My preference would be to avoid this entirely, as it is a bottomless pit of pain! Depending on what you are doing with email addresses, perhaps you can validate them by sending a message and obtaining a response (click-through link or similar)?