Regex for email address

/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g

Options
Matches

Examples

Note

Good enough to find addresses in text and catch typos in a form. The full RFC 5322 grammar allows far more (quoted local parts, IP-literal domains); the only real test of an address is sending it a message.

Matches in the example

  • "ana@example.com"
  • "bob.smith+news@mail.co.uk"

Token by token

  1. [A-Za-z0-9._%+-]+ one of: “A” to “Z”, “a” to “z”, “0” to “9”, “.”, “_”, “%”, “+” or “-”, one or more times, as many as possible
  2. @ the character “@”
  3. [A-Za-z0-9.-]+ one of: “A” to “Z”, “a” to “z”, “0” to “9”, “.” or “-”, one or more times, as many as possible
  4. \. the character “.”
  5. [A-Za-z]{2,} one of: “A” to “Z” or “a” to “z”, 2 or more times, as many as possible

Other patterns