preg_replace to conditionally replace twitter hashtag and user mentions with urls

Linkify your twitter hashtags and twitter user mentions! Need to replace twitter hashtags and usernames with the actual Twitter hashtag search query links/URLs and user profile pages?

Twitter Username / User Mention Preg_replace


Twitter Hashtag Preg_replace


This can come in handy when trying to display tweets on your WordPress theme, or really any website! If you are using wordpress, a great plugin to start off with would be oAuth Twitter Feed for Developers