email validation question [abnf] [RF 5322]
What does the following mean in the sentence below 1*( atext / "." ) "@" ldh-str 1*( "." ldh-st开发者_运维百科r )
Could someone break it down in simple terms?
Any string that matches the following [ABNF] production:
1*( atext / "." ) "@" ldh-str 1*( "." ldh-str )
Where atext is as defined in [RFC 5322], and ldh-str is as defined in [RFC 1034].
1*( atext / "." ) "@" ldh-str 1*( "." ldh-str )
is a definition for a well-formatted e-mail address.
1*
is pretty much telling you that (atext / ".")
must be repeated once or more before the @ symbol. atext
can be any alphanumeric character (must start with a non-digit) and you are allowed to include dots to separate characters.
Consider this: @example.com
is not a valid e-mail address. a@example.com
is.
ldh-str
is basicaly a string representing a second level domain string while 1*("." ldh-str )
is the top level domain.
a@.com
is also not a valid address.
Check the following pages for more details:
- RFC5322
- RFC1034
ABNF is Augmented Backus-Naur Form, which is a syntax for describing a grammar. Looks like there's a pretty good reference on Wikipedia.
For the definitions of atext
and ldh-str
, check out the relevant RFCs (Requests For Comments - basically internet standards):
- RFC 5322 (which is about a standard Internet message format, aka "email")
- RFC 1034 (which is about domain names)
(Note that the place you copied and pasted the definition from actually has links to references for these things if you'd clicked on the bits in square brackets...)
If you have any more questions after reading these sources, let us know...
精彩评论