JSFiddle - React, Tailwind, and code Playground

HTML

<div id="test">
    
</div>

JavaScript

text = "http://stackoverflow.com/questions/579335/javascript-regexp-to-wrap-urls-and-emails-in-anchors";
		result = replaceURLWithHTMLLinks(text);
		$("#test").html(result);


		function replaceURLWithHTMLLinks(text) {
		    var exp = /(\b(http|ftp|https):\/\/([\w-]+\.[\w-]+)+([\w.,@?^=%&amp;:\/~+#-]*[\w@?^=%&amp;\/~+#-])?)/ig;
		    return text.replace(exp,"<a href='$1'>$3</a>"); 
		}