I found the following regex:
/[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/
on this site: http://www.regular-expressions.info/email.html
and it works great (matches 99.99% of actual emails), with one exception. It allows you to append anything you want after the domain.
example:
test does not match
test@domain does not match
[email protected] does match
[email protected] does match
[email protected]#()%@dsf,25ljsafdlfkjj&45234^\/3258afsd still matches
I also only want to validate a single email at a time, so the following string should not match, despite being valid in an email client: [email protected];[email protected]
This is being used by javascript.
^
on the beggining and$
at the end ? – DontVoteMeDown[email protected]
#()%@dsf,25ljsafdlfkjj&45234^\/3258afsd. It does not match the un-highlighted part. I don't know what you mean by it still matches. You are trying to match the valid email aren't you? – user557597