Skip to content

Instantly share code, notes, and snippets.

@dawnerd
Created December 16, 2011 02:38
Show Gist options
  • Save dawnerd/1484178 to your computer and use it in GitHub Desktop.
Save dawnerd/1484178 to your computer and use it in GitHub Desktop.
Parse Tweet text
function parseTweet(text) {
return text.replace(/[\w]+:\/\/[\w\d-]+\.[\w\d-:%&~\?\/.=]+/gi, function(url) {
return url.link(url);
}).replace(/[@]+[\w\d-]+/gi, function(u) {
return u.link("http://twitter.com/"+u.replace("@",""));
}).replace(/[#]+[\w\d-]+/gi, function(t) {
return t.link("http://search.twitter.com/search?q="+t.replace("#","%23"));
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment