Regex for email address
/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g
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
[A-Za-z0-9._%+-]+one of: “A” to “Z”, “a” to “z”, “0” to “9”, “.”, “_”, “%”, “+” or “-”, one or more times, as many as possible@the character “@”[A-Za-z0-9.-]+one of: “A” to “Z”, “a” to “z”, “0” to “9”, “.” or “-”, one or more times, as many as possible\.the character “.”[A-Za-z]{2,}one of: “A” to “Z” or “a” to “z”, 2 or more times, as many as possible
Other patterns
- Email address
- URL
- IPv4 address
- UUID
- Hex color
- Date (YYYY-MM-DD)
- Time (24-hour)
- US phone number
- Phone number (E.164)
- US ZIP code
- Credit card number
- URL slug
- Username
- Strong password
- HTML tag
- Semantic version
- MAC address
- JSON Web Token
- Hashtag
- @mention
- Number
- Leading and trailing whitespace
- Repeated word
- Blank lines
- Markdown link
- Quoted string
- Domain name
- File extension
- Base64
- Trailing comma