let bodyhtml = ‘’
let bodyc = ‘贾玲带“李焕英”来三亚了!https://mbd.baidu.com/newspage/data/landingsuper?context=%7B%22nid%22%3A%22news_9943695772292681924%22%7D&n_type=0&p_from=1https://mbd.baidu.com对30亿元票房,
她说……’
//内容换行
bodyhtml = bodyc.replace(/\n/g, '<br>');
//网址处理
//var reg = /(((https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/ig;
let reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
bodyhtml = bodyhtml.replace(reg, function(item) {
return "<a href='" + item + "' target='_blank' class='texthttp'>" + item + "</a>";
});
参考https://www.cnblogs.com/lr-blog/p/6042694.html