查找:(http://.*?com)替换:<a href="$1">$1</a>替换http://www.baidu.com为<a href="http://www.baidu.com">http://www.baidu.com</a>
var reg = /(http\:[\w\.\/]+)/gim;var url = "比如:http://www.baidu.com 吧文本框中 http开头,com结尾的都加上超链接";url = url.replace(reg, "<a href='$1'>$1</a>");console.log(url);