Skip to content

Instantly share code, notes, and snippets.

@rodolfofadino
Created May 21, 2012 01:14
Show Gist options
  • Save rodolfofadino/2760167 to your computer and use it in GitHub Desktop.
Save rodolfofadino/2760167 to your computer and use it in GitHub Desktop.
Some regex's to format the content in the tweet
// Some regex's to format the content in the tweet
tweet.text = tweet.text.replace(/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi, '<a href="$1" target="_blank">$1<\/a>');
tweet.text = tweet.text.replace(/@([a-zA-Z0-9_]+)/gi, '<a href="http://twitter.com/$1" target="_blank" class="username">@$1<\/a>');
tweet.text = tweet.text.replace(/#([a-zA-Z0-9_]+)/gi, '<a href="http://search.twitter.com/search?q=%23$1" target="_blank" class="hashtag">#$1<\/a>');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment