Return to Snippet

Revision: 12783
at March 28, 2009 14:03 by troynt


Initial Code
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;
	}

Initial URL


Initial Description


Initial Title
Convert Text URLs into Links

Initial Tags
regex, javascript

Initial Language
JavaScript