showing results for - "js replace text link with anchor tags"
Jeanne
27 Jan 2017
1var exp_match = /(\b(https?|):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
2   var element_content=content.replace(exp_match, "<a href='$1'>$1</a>");
3   var new_exp_match =/(^|[^\/])(www\.[\S]+(\b|$))/gim;
4   var new_content=element_content.replace(new_exp_match, '$1<a target="_blank" href="http://$2">$2</a>');