/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
linkify_plain:function(text) { if( !text ) return text; text = text.replace(/((https?\:\/\/|ftp\:\/\/)|(www\.))(\S+)(\w{2,4})(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi,function(url){ nice = url; if( url.match('^https?:\/\/') ) { nice = nice.replace(/^https?:\/\//i,'') } else url = 'http://'+url; return '<a target="_blank" rel="nofollow" href="'+ url +'">'+ nice.replace(/^www./i,'') +'</a>'; }); return text; }
Comments
