I'm trying to build a regular expression to detect a valid email. I've gone through some articles here on Stack Overflow. I've also read the section 3.4.1 of RFC 2822, which describes the different components of an email address:
addr-spec = local-part "@" domain
local-part = dot-atom / quoted-string / obs-local-part
domain = dot-atom / domain-literal / obs-domain
domain-literal = [CFWS] "[" *([FWS] dcontent) [FWS] "]" [CFWS]
dcontent = dtext / quoted-pair
dtext = NO-WS-CTL / ; Non white space controls
%d33-90 / ; The rest of the US-ASCII
%d94-126 ; characters not including "[",
; "]", or "\"
In simple English, can someone explain the definition above? Does it allow for an email such as info@[192.168.0.1]
?
I know that I don't have to re-invent the wheel, and that there are good libraries that I can use to validate an email. I just want to understand how things work under the hood.