This question on SO led me to this website which have a bunch of explanation on email validation. The last regex seems the most accurate and recommended. I've searched SO for this regex but the implementations I found slightly differ.
I would like to test the following regex provided on the website with my current set of emails and make some tests.
I tried to make the title and this question as precise as possible (for you and the search engines), feel free to suggest edits.
The regex in question is the following:
\A(?=[a-z0-9@.!#$%&'*+/=?^_`{|}~-]{6,254}\z)
(?=[a-z0-9.!#$%&'*+/=?^_`{|}~-]{1,64}@)
[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*
@ (?:(?=[a-z0-9-]{1,63}\.)[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+
(?=[a-z0-9-]{1,63}\z)[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\z
I escaped the /
characters but it still doesn't seem to work for some reason.
My goal is to use this regex like so:
const regexEmail = new RegExp("...")
I created a sandbox for this regex available on regex101, but the email address is not found.
I am no pro at regex and usually get only pre made stuff. The help of this community is greatly appreciated.