Web url checking


[FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]var[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][COLOR=#000000] expression = /^[a-zA-Z0-9\\-\\.\\/]+\\.(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU)$/;[/COLOR]

Above expression is failing the urls where we have path available after .edu. How can i fix the expression that it supports these urls also?


Also, am i limiting the user by specifying certain tlds? Should i change this too?


changed the expression to following and it is checking what i am looking for (hopefully i am not overlooking some thing):
var expression = new RegExp(“^([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|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|[a-zA-Z]{2}))(\:[0-9]+)(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$”);


I’m sure if someone tried, they could make it fail. But yes, that looks a bit more serious. I think there are so many possible variations that it’s almost not worth it. You might as well just check there is a dot in it and that’s it.

haha, I agree. I’ve had a similar situation in the past when checking the URL and just decided to put a note of what I am expecting from the user and did a general check.