I have to make a regular expression for the email addresses (RFC 822) and I want to know which characters are allowed in the local part and in the domain.
I found this https://www.rfc-editor.org/rfc/rfc822#section-6.1 but I don't see that it says which are the valid characters.
According to RFC 822, the local part may contain any ASCII character, since
local-part
is defined usingword
, which is defined asatom / quoted-string
;atom
covers most ASCII characters, and the rest can be written in aquoted-string
. There are syntactic restrictions, but obeying them, any ASCII character can be used.On similar grounds, RFC 822 allows any ASCII character in the
domain
part.On the other hand, RFC 822 was obsoleted in 2001 by RFC 2822, which in turn was obsoleted in 2008 by RFC 5322. The status of RFCs can be checked from the RFC Editor’s RFC database.