String.prototype.linkify = function() {
this.replace(/((ht|f)tp:\/\/)?([^:\/\s]+)\w+.(com|net|org)/gi, '<a href="$&">$&</a>')
}
with http://www.google.com http://yahoo.com www.facebook.com it matches them all, however I want facebook to be prepended with the protocol group if it does not exist. Is there a way to do this without doing two .replace ?
I would do something like this:
(I fixed a couple of other problems with your code: you were missing a
returnand you were matching the domain name period using.rather than\..)And I assume I don’t need to point out how poorly this will match URL:s in general, due to a number of problems with your pattern.