According to the RFC-822 of mail address validation, there is a monster PERL-based Regular Expression with actually so many errors when I tried to use it in online regex testers:
(?:(?:
)?[ ])*(?:(?:(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ]
)+||(?=[["()<>@,;:".[]]))|"(?:[^"
\]|\.|(?:(?:
)?[ ]))*"(?:(?:
)?[ ])*)(?:.(?:(?:
)?[ ])*(?:[^()<>@,;:".[] 00-31]+(?:(?:(
?:
)?[ ])+||(?=[["()<>@,;:".[]]))|"(?:[^"
\]|\.|(?:(?:
)?[
]))*"(?:(?:
)?[ ])*))*@(?:(?:
)?[ ])*(?:[^()<>@,;:".[] 00-
31]+(?:(?:(?:
)?[ ])+||(?=[["()<>@,;:".[]]))|[([^[]
\]|\.)*
](?:(?:
)?[ ])*)(?:.(?:(?:
)?[ ])*(?:[^()<>@,;:".[] 00-31]+
(?:(?:(?:
)?[ ])+||(?=[["()<>@,;:".[]]))|[([^[]
\]|\.)*](?:
(?:
)?[ ])*))*|(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ])+|
|(?=[["()<>@,;:".[]]))|"(?:[^"
\]|\.|(?:(?:
)?[ ]))*"(?:(?:
)
?[ ])*)*<(?:(?:
)?[ ])*(?:@(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
r
)?[ ])+||(?=[["()<>@,;:".[]]))|[([^[]
\]|\.)*](?:(?:
)?[
])*)(?:.(?:(?:
)?[ ])*(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)
?[ ])+||(?=[["()<>@,;:".[]]))|[([^[]
\]|\.)*](?:(?:
)?[ ]
)*))*(?:,@(?:(?:
)?[ ])*(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[
])+||(?=[["()<>@,;:".[]]))|[([^[]
\]|\.)*](?:(?:
)?[ ])*
)(?:.(?:(?:
)?[ ])*(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ]
)+||(?=[["()<>@,;:".[]]))|[([^[]
\]|\.)*](?:(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
?:(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ])+||(?=[["()<>@,;:\
".[]]))|"(?:[^"
\]|\.|(?:(?:
)?[ ]))*"(?:(?:
)?[ ])*)(?:.(?:(
?:
)?[ ])*(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ])+||(?=[
["()<>@,;:".[]]))|"(?:[^"
\]|\.|(?:(?:
)?[ ]))*"(?:(?:
)?[
])*))*@(?:(?:
)?[ ])*(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[
])+||(?=[["()<>@,;:".[]]))|[([^[]
\]|\.)*](?:(?:
)?[ ])*)(?
:.(?:(?:
)?[ ])*(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ])+|
|(?=[["()<>@,;:".[]]))|[([^[]
\]|\.)*](?:(?:
)?[ ])*))*|(?:
[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ])+||(?=[["()<>@,;:".[
]]))|"(?:[^"
\]|\.|(?:(?:
)?[ ]))*"(?:(?:
)?[ ])*)*<(?:(?:
)
?[ ])*(?:@(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ])+||(?=[["
()<>@,;:".[]]))|[([^[]
\]|\.)*](?:(?:
)?[ ])*)(?:.(?:(?:
)
?[ ])*(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ])+||(?=[["()<>
@,;:".[]]))|[([^[]
\]|\.)*](?:(?:
)?[ ])*))*(?:,@(?:(?:
)?[
])*(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ])+||(?=[["()<>@,
;:".[]]))|[([^[]
\]|\.)*](?:(?:
)?[ ])*)(?:.(?:(?:
)?[ ]
)*(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ])+||(?=[["()<>@,;:\
".[]]))|[([^[]
\]|\.)*](?:(?:
)?[ ])*))*)*:(?:(?:
)?[ ])*)?
(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ])+||(?=[["()<>@,;:".
[]]))|"(?:[^"
\]|\.|(?:(?:
)?[ ]))*"(?:(?:
)?[ ])*)(?:.(?:(?:
)?[ ])*(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ])+||(?=[[
"()<>@,;:".[]]))|"(?:[^"
\]|\.|(?:(?:
)?[ ]))*"(?:(?:
)?[ ])
*))*@(?:(?:
)?[ ])*(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ])
+||(?=[["()<>@,;:".[]]))|[([^[]
\]|\.)*](?:(?:
)?[ ])*)(?:
.(?:(?:
)?[ ])*(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ])+|
|(?=[["()<>@,;:".[]]))|[([^[]
\]|\.)*](?:(?:
)?[ ])*))*>(?:(
?:
)?[ ])*))*)?;s*)
The question is "why?"
Isn't any shorter Regular expression out there that does verify email addresses simple, accurate and yet fast? Like what is used in so many frameworks?
and as you see it's not there just for reading! It's used in a module and it means it's built for real world!
However there are so many cases in this expression that just made it long and long like
[^[]
\]
which can be replaced by [^][
\]
I think that RFC, as an standard, should state the most acceptable things to all not within complexity and mind-blowing!
Update
Beside all words above, I should say that the online validator, that page refers to, tells revo@test&^%$#|.com
is a valid email address however as RFC-1035 and we know, domain names
must start with a letter, end with a letter or digit, and have as
interior characters only letters, digits, and hyphen. There are also
some restrictions on the length.
Question&Answers:
os