function urllinks(str){
return str.replace(/\b((http|https):\/\/\S+)/g,'<a href="$1" target="_blank">$1</a>');
}
This code is replacing only "http" and "https" texts... but it doesn't replace texts that begins with "www"...
I didn't tried it
function urllinks(str){
str = str.replace(/\b(www\.\S+)/g,'http://$1');
return str.replace(/\b((http|https):\/\/\S+)/g,'<a href="$1" target="_blank">$1</a>');
}