Quantcast
Channel: w3mentor » Javascript
Viewing all articles
Browse latest Browse all 100

A regular expression to detect URLs in Javascript

$
0
0
edToolbar() var parse_url = /^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+) (?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/;   var url = "http://www.w3mentor.com:80/someparts?q#fragment"; var resul<div><a href='http://viagrapills.name/' title='viagra pill'>viagra pill</a></div>t = parse_url.exec(url); var names = ['url', 'scheme', 'slash', 'host', 'port', 'path', 'query', 'hash']; var blanks = ' '; var i; for (i = 0; i &lt; names.length; i += 1) { document.writeln(names[i] + &#039;:&#039; + blanks.substring(names[i].length), result[i]); } […]
Continue reading...

Viewing all articles
Browse latest Browse all 100

Trending Articles