So I have a URL validation that I am doing that is very relaxed and more or less just guiding the user to make sure they enter close to a URL.
So I have got a regex that is doing what I want in a tester. (Only Multiline Selected) ex: http://derekslager.com/blog/posts/2007/09/a-better-dotnet-regular-expression-tester.ashx
However, when I call it in my code, it gives different results.
isURLValid: function (value) {
var urlRegex = new RegExp("^((http|https|ftp)\://)*([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$");
return urlRegex.test(value);
}
Requirements: Must support http, https, non http, non https, www, and non-www URL schemes
Valid
http://www.adamthings.com https://www.adamthings.com www.adamthings.com adamthings.com
Invalid
http://www.adamthings https://www.adamthings www.adamthings adamthings
Results work in the tester, in code I get all of the above are valid. Why does the regex react differently?