function replaceURLTextWithLink(text) { // Put the URL to variable $1 after visiting the URL const Rexp =/((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g; // Replace the RegExp content by HTML element return text.replace(Rexp, "<a href='$1' target='_blank'>$1</a>"); }