Skip to content

Instantly share code, notes, and snippets.

@paatsinsuwan
Created July 31, 2011 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paatsinsuwan/1117350 to your computer and use it in GitHub Desktop.
Save paatsinsuwan/1117350 to your computer and use it in GitHub Desktop.
linkify all @screen_name and #hashtag
/*
* credited to Stephen Granade
* http://granades.com/
*/
String.prototype.linkify_tweet = function() {
var tweet = this.replace(/(^|\s)@(\w+)/g, '$1@<a href="http://www.twitter.com/$2">$2</a>');
return tweet.replace(/(^|\s)#(\w+)/g, '$1#<a href="http://search.twitter.com/search?q=%23$2">$2</a>');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment