At least in human languages, a rich one allows you to say the same thing in many different ways... at least in human languages...
today I was wandering in some community and stopped by a post of someone asking to explain this javascript code:
function emailCheck(email)
{
var tmp = "" + email + "", s = tmp.replace(/^\s*|\s*$/g, "");
var re = /^(\w|[^_]\.|[\-])+((\@){1}([^_]))(([a-z
]|[\d]|[\-]|\.)+|([^_]\.[^_])*)+\.[a-z]{
2,3}$/i
if (!re.test(s))
{
return false;
}
re = /\.(a[c-gil-oq-uwz]|b[a-bd-jm-or-tvwyz]|
c[acdf-ik-orsuvx-z]|d[ejkmoz]|e[ceghr-u]
|f[i-kmorx]|g[abd-ilmnp-uwy]|h[kmnrtu]|i
[delm-oq-t]|j[emop]|k[eg-imnprwyz]|l[a-c
ikr-vy]|m[acdghk-z]|n[ace-giloprtuz]|om|
p[ae-hk-nrtwy]|qa|r[eouw]|s[a-eg-ort-vyz
]|t[cdf-hjkm-prtvwz]|u[agkmsyz]|v[acegin
u]|w[fs]|y[etu]|z[admrw]|com|edu|net|org
|mil|gov|biz)$/i
if (!re.test(s))
{
return false;
}
re = /\@\@/
return(!re.test(s));
}
(please don't complain about the indentation or wrapping, this is the way that community's software shows it, in fact I'm copying it directly from the page's source)
well I explained and made my own version:
function emailCheck(email) {
// declare valid TLDs
var TLD = 'aero|biz|cat|com|coop|info|jobs|mobi|mu
seum|name|net|org|pro|travel|gov|edu|mil
|int';
var ccTLD = 'ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|
at|au|aw|ax|az|' +
'ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|
bs|bt|bv|bw|by|bz|' +
'ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|
cu|cv|cx|cy|cz|' +
'de|dj|dk|dm|do|dz|' +
'ec|ee|eg|eh|er|es|et|eu|' +
'fi|fj|fk|fm|fo|fr|' +
'ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|
gr|gs|gt|gu|gw|gy|' +
'hk|hm|hn|hr|ht|hu|' +
'id|ie|il|im|in|io|iq|ir|is|it|' +
'je|jm|jo|jp|' +
'ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|' +
'la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|' +
'ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|
mr|ms|mt|mu|mv|mw|mx|my|mz|' +
'na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|' +
'om|' +
'pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|
py|' +
'qa|' +
're|ro|rs|ru|rw|' +
'sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|
so|sr|st|su|sv|sy|sz|' +
'tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|
tt|tv|tw|tz|' +
'ua|ug|uk|um|us|uy|uz|' +
'va|vc|ve|vg|vi|vn|vu|' +
'wf|ws|' +
'ye|yt|yu|' +
'za|zm|zw';
// define 'email-like' regexp
var re = new RegExp('^[A-Z0-9._%-]+@[A-Z0-9-]+(\.[A-Z
0-9-]+)*(\.(' + TLD + '|' + ccTLD + '))$', 'i');
// trim parameter
email = email.toString().replace(/^\s*|\s*$/g, '');
return re.test(email);
}
I must admit that felt a bit like this, but it left me thinking -how good- it is to have lots of ways to do the same thing in programming languages...