var reg = /(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|&|-)+)/g;
c = c.replace(reg, "<a href='$1$2' target='_blank'>$1$2</a>").replace(/\n/g, "");

代码整理自:http://www.oschina.net/code/snippet_197014_12209

Related Posts: jQuery-正则http地址自动变成可访问的url :