JSFiddle - React, Tailwind, and code Playground
HTML
http://stackoverflow.com/
<a href="http://stackoverflow.com/">Stack Overflow</a>
<textarea>
http://stackoverflow.com/
</textarea>
<script>
var a = "http://stackoverflow.com/";
</script>
JavaScript
function autolink() {
var exp = /(\b(https?|ftp):\/\/[-A-Z0-9+\u0026@#\/%?=~_|!:,.;]*[-A-Z0-9+\u0026@#\/%=~_|])/gi,
lt = '\u003c',
gt = '\u003e';
$('*:not(a, script, style, textarea)').contents().each(function() {
if (this.nodeType == Node.TEXT_NODE) {
var textNode = $(this);
var span = $(lt + 'span/' + gt).text(this.nodeValue);
span.html(span.html().replace(exp, lt + 'a href=\'$1\'' + gt + '$1' + lt + '/a' + gt));
textNode.replaceWith(span);
}
});
}
$(autolink);