Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript replace url on sentence as achor

    var url_replacer = function (str) {
        let match = str.match(/((https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig);
        let final = str;
        if (match) { /// if nulled
            match.map(url => {
                final = final.replace(url, "<a href="" + url + "" target="_BLANK">" + url + "</a>");
            });
            return final;
        }else{
            return str;
        }
    };
Comment

PREVIOUS NEXT
Code Example
Javascript :: making a react js website project ready for hosting 
Javascript :: fastest way to sort an array html tags front 
Javascript :: check if device is in dark mode js 
Javascript :: how to call url multiple times 
Javascript :: the key import is reserved 
Javascript :: discord.js get message content 
Javascript :: How display console log in frontend 
Javascript :: data toggle modal and tooltip 
Javascript :: react native asyncstorage getitem 
Javascript :: gitignore jsconfig 
Javascript :: jwt sign options 
Javascript :: execute shell command from html button node js 
Javascript :: keep records of number rolled in array javascript 
Javascript :: convert typescript to js online 
Javascript :: get position of an object inside a container phaser 3 
Javascript :: AssertionError [ERR_ASSERTION]: Expected values to be loosely deep-equal: 
Javascript :: upload image in react next js authentication 
Javascript :: crear un texto dinamicamente con javascript 
Javascript :: setImmediate clearImmediate 
Javascript :: csvString to json 
Javascript :: get data form and map in react js 
Javascript :: Paginate array in JavaScript 
Javascript :: where is the waypoint json file lunar client mac 
Javascript :: url is not a constructor javascript 
Javascript :: react native red Triangle Down 
Javascript :: function last character return 
Javascript :: fs keep file open 
Javascript :: for getting options id using javascript 
Javascript :: force https nuxt heroku 
Javascript :: moment js formating to one day less using zulu time 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =