Within the code snippet below, the regular expression in the "pattern" variable is specifically designed to only match the criteria mentioned in the comment (which requires a minimum of 1 letter followed by a dot, and then two letters).
var link = "Help"
// matches www-data.it -- needs at least (1 letter + '.' + 2 letters )
var pattern = '((xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}';
var re2 = new RegExp('^' + pattern, 'i');
// if no http and there is something.something
if (link.search(re2) == 0)
{
link = link;
}
Testing this code on shows successful results as expected, where only strings with the format something.something pass.
However, testing it on JSFiddle and in live production results in unexpected matches such as "Help." http://jsfiddle.net/2jU4D/
This discrepancy raises questions about the functionality of the code. What could be causing this inconsistency?