Phil
Phil

Reputation: 4224

Email Regex for single character domain names

I have the following regex that only works with two letter domains or more. I need this to work with single letter domains as well. Please suggest changes to the regex below.

^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$

Upvotes: 2

Views: 766

Answers (2)

Phil
Phil

Reputation: 4224

This regex will cover single letter domains.

\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

Upvotes: 0

Eugene K
Eugene K

Reputation: 3457

\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b 

Upvotes: 1

Related Questions