There are so many post about url validation using regular expression. I got this Link expression and create a function which validate url. Everything is working fine but i want "some.com" also true, which is i am getting false. I tried with some regular exp for empty string like ^$ but not working fine!
function is_url(url)
{
if(/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/|www\.)[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/.test(url))
{
return true
}
else
{
return false
}
}
Result:
https:\\www.some.com - true
http:\\www.some.com - true
http:\\some.com - true
www.some.com - true
some.com - false // i want this also true
Any Help?