JSFiddle - React, Tailwind, and code Playground
by webvitaly
HTML
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
src:
<div class="well target">
google: https://www.google.com/
google secured: http://www.google.com/
</div>
result:
<div class="well result"></div>
JavaScript
function url_to_link(text) {
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(exp,"<a href='$1'>$1</a>");
}
$(function(){
var text = $('.target').html();
$('.result').html( url_to_link(text) );
});