Regex to match urls using JavaScript -


i'm using regex far has been pretty good...

var r = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\s+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi; 

but if have string such following...

 '<div>http://www.a-random-site.com/page1-blah-blah</div>another bit of text' 

then bit matched be...

http://www.a-random-site.com/page1-blah-blah</div>another 

how can alter regex take account angled bracked terminate link?

i edited saram's regex pattern , tested expresso , worked sample :

(?:http|ftp|https):\/\/[\w\-_]+(?:\.[\w\-_]+)+(?:[\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])? 

Popular posts from this blog

Php - Delimiter must not be alphanumeric or backslash -

c# - How to change the "Applies To" field under folder auditing options programatically (.NET) -

c++ - Ambiguity when using boost::assign::list_of to construct a std::vector -