Javascript String autolink()
String.prototype.autolink = function () { return this.toString().replace(/((https?:\/\/|www\.)[^'"\s]*)/gi,'<a href="$1">$1</a>'); };
String.prototype.autoLink = function() { var pattern = /(^|\s)((?:https?|ftp):\/\/([\-A-Z0-9+\u0026@#\/%?=()~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~()_|]))/gi; var currentHost = document.location.host; return this.replace(pattern, function(match, space, url, urlWithoutProto) { return space + '<a' + ' href="' + url + '"' + (urlWithoutProto.split('/', 2)[0] !== currentHost ? ' target="_blank"' : '') + '>' + urlWithoutProto + '</a>'; });/* w ww.j a va2 s. c om*/ };