Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript link detector

function URLReplacer(str){
        let match = str.match(/((https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig);
        let final=str;
        match.map(url=>{
            final=final.replace(url,"<a href=""+url+"" target="_BLANK">"+url+"</a>")
        })
        return final;
      }
 
PREVIOUS NEXT
Tagged: #javascript #link #detector
ADD COMMENT
Topic
Name
4+9 =