Replace URL's with Links

PHOTO EMBED

Fri Jan 26 2024 18:02:01 GMT+0000 (Coordinated Universal Time)

Saved by @marcopinero #javascript

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>");
}
content_copyCOPY

Function for replacing URL's in text by link (anchor tag).