Thursday, October 28, 2004

Really Frightening Codes (RFC)

How did RFC become Really Frightening Codes?

A few days ago, my fellow blogger, sriram mailed me the regular expression for finding out the validity of email addresses. Then I began reading the underlying RFC and this is what I learnt from it:

"There's always the easy way and the hard way. And, unfortunately, it seems that the hardest way is always the most correct way too. Almost always"

Life's got too many examples for this. Let me post two of it:

1. Parsing an Email address:
The supposedly correct way for doing it is here:
http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
And the program to generate the regex is here:
http://www.ex-parrot.com/~pdw/Mail-RFC822-Address/Mail-RFC822-Address-0.4.tar.gz


2. Parsing an URL:
The RFC (and, you guessed it, the hard)way of doing it right:
http://www.foad.org/~abigail/Perl/url3.regex
And the program that would generate the behemoth:
http://www.foad.org/~abigail/Perl/url3.pl

But you've got to be wise in choosing a way when there is an easy way and a hard way. Because of the presence of those cute things called "exceptions". Now, the RFC equivalent of email address and url parsing are a bit old. They include regex to cover the following types of email addresses too:

Alfred Neuman@BBN-TENEXA
:sysmail"@ Some-Group. Some-Org
Muhammed.(I am the greatest) Ali @(the)Vegas.WBA


Now really! Valid? These are unheard of in the real world, people. So, you see, there are exceptions and they are cute too.

Now I Request For Comment.

No comments: