Return to Snippet

Revision: 41936
at February 25, 2011 04:36 by naren1012


Updated Code
function tweetify(text) {
    text = text.replace(/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:(?:[^\s()<>.]+[.]?)+|\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\))+(?:\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?���«���»�¢ï¿½ï¿½�¢ï¿½ï¿½�¢ï¿½ï¿½�¢ï¿½ï¿½]))/gi,
					"<a target=_blank href=$1>$1</a>");
    text = text.replace(/[\@]+([A-Za-z0-9-_]+)/gi, "<a target=_blank href=http://twitter.com/$1>@$1</a>");
    return text.replace(/(?:^| )[\#]+([A-Za-z0-9-_]+)/gi, " <a target=_blank href=http://search.twitter.com/search?q=&tag=$1&lang=all>#$1</a>");
}

Revision: 41935
at February 25, 2011 04:35 by naren1012


Updated Code
function tweetify(text) {
    text = text.replace(/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:(?:[^\s()<>.]+[.]?)+|\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\))+(?:\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?�«�»â��â��â��â��]))/gi,
					"<a target=_blank href=$1>$1</a>");
    text = text.replace(/[\@]+([A-Za-z0-9-_]+)/gi, "<a target=_blank href=http://twitter.com/$1>@$1</a>");
    return text.replace(/(?:^| )[\#]+([A-Za-z0-9-_]+)/gi, " <a target=_blank href=http://search.twitter.com/search?q=&tag=$1&lang=all>#$1</a>");
}

Revision: 41934
at February 25, 2011 02:42 by naren1012


Updated Code
function tweetify(text) {
    text = text.replace(/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:(?:[^\s()<>.]+[.]?)+|\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\))+(?:\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»����]))/gi,
					"<a target=_blank href=$1>$1</a>");
    text = text.replace(/[\@]+([A-Za-z0-9-_]+)/gi, "<a target=_blank href=http://twitter.com/$1>@$1</a>");
    return text.replace(/(?:^| )[\#]+([A-Za-z0-9-_]+)/gi, " <a target=_blank href=http://search.twitter.com/search?q=&tag=$1&lang=all>#$1</a>");
}

Revision: 41933
at February 25, 2011 02:41 by naren1012


Initial Code
function tweetify(text) {
    text = text.replace(/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:(?:[^\s()<>.]+[.]?)+|\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\))+(?:\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi,
					"<a target=_blank href=$1>$1</a>");
    text = text.replace(/[\@]+([A-Za-z0-9-_]+)/gi, "<a target=_blank href=http://twitter.com/$1>@$1</a>");
    return text.replace(/(?:^| )[\#]+([A-Za-z0-9-_]+)/gi, " <a target=_blank href=http://search.twitter.com/search?q=&tag=$1&lang=all>#$1</a>");
	return text;
}

Initial URL


Initial Description
This is 3 lines of javascript code to tweetify plain text returned by Twitter API

Input : RT @TTintheCloud: How much are free #cloudcomputing trial offers from Google, Amazon and Microsoft actually WORTH? http://bit.ly/i4w4qa

Output : RT <a href="http://twitter.com/TTintheCloud">@TTintheCloud</a>: How much are free <a href="http://search.twitter.com/search?q=&amp;tag=cloudcomputing&amp;lang=all">#cloudcomputing</a> trial offers from Google, Amazon and Microsoft actually WORTH? <a href="http://bit.ly/i4w4qa">http://bit.ly/i4w4qa</a>

Initial Title
Tweetify Plain Text

Initial Tags
javascript

Initial Language
JavaScript