Skip to main content
Source Link
Andrew
  • 3.4k
  • 5
  • 37
  • 45

I have found this to be the best solution:

/^[^\s@]+@[^\s@]+\.[^\s@]+$/

It allows the following formats:

1.  [email protected]
2.  [email protected]
3.  [email protected]
4.  [email protected]
9.  #!$%&'*+-/=?^_`{}|[email protected]
6.  "()[]:,;@\\\"!#$%&'*+-/=?^_`{}| ~.a"@example.org
7.  " "@example.org (space between the quotes)
8.  üñîçøðé@example.com (Unicode characters in local part)
9.  üñîçøðé@üñîçøðé.com (Unicode characters in domain part)
10. Pelé@example.com (Latin)
11. δοκιμή@παράδειγμα.δοκιμή (Greek)
12. 我買@屋企.香港 (Chinese)
13. 甲斐@黒川.日本 (Japanese)
14. чебурашка@ящик-с-апельсинами.рф (Cyrillic)

It's clearly versatile and allows the all-important international characters, while still enforcing the basic [email protected] format. It will block spaces which are technically allowed by RFC, but they are so rare that I'm happy to do this.

Post Made Community Wiki by Andrew