Let\'s imagine I have this text:
Hi, my name is Pablo and my home page is http://zad0xsis.net
You could use a regex:
var s = 'Hi, my name is Pablo and my home page is http://zad0xsis.net'; var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; s = s.replace(exp,"$1"); alert(s);
Live demo.