showing results for - "javascript link detector"
Edoardo
12 Apr 2017
1function URLReplacer(str){
2        let match = str.match(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig);
3        let final=str;
4        match.map(url=>{
5            final=final.replace(url,"<a href=\""+url+"\" target=\"_BLANK\">"+url+"</a>")
6        })
7        return final;
8      }