3 ms·
Can somebody explain why it has to be so long? Are there so many special cases?
by valevk 12y ago
Can somebody explain why it has to be so long? Are there so many special cases?
- Xophmeister 12y agoHave a read of RFC 2822[1] section 3.4 In brief, the address specification may look like the simple "local" @ "domain", but those subparts can be non-regular (i.e., making them hard/impossible for a regular expression engine to parse) or contain a lot of exceptions (e.g., the domain could be google.com, or it could be 12.34.56.78, or localhost, or a number of other things). [1] https://www.ietf.org/rfc/rfc2822.txt https://www.ietf.org/rfc/rfc2822.txt
- hornetblack 12y agoIt's not a regular grammar. Regular expressions were designed to handle regular grammar, and there are cases where something that looks valid is actually invalid: ex@256.255.255.255. (See the above posters link: https://nikic.github.io/2012/06/15/The-true-power-of-regular-expressions.html https://nikic.github.io/2012/06/15/The-true-power-of-regular...)