I think the question title seems to explain eveything. I want to detect whether a string is in URL format or not using javascript.
Any help appreciated.
I think the question title seems to explain eveything. I want to detect whether a string is in URL format or not using javascript.
Any help appreciated.
try something like this:
function isUrl(s) {
var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)? (\/|\/([\w#!:.?+=&%@!\-\/]))?/
return regexp.test(s);
}
taken from http://snippets.dzone.com/posts/show/452
You can use a regular expression for checking the string
^s?https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+$