Title: Twitter Feed Regular Expressions
Last modified: August 19, 2016

---

# Twitter Feed Regular Expressions

 *  [Tom Lany](https://wordpress.org/support/users/tomthewebmaster/)
 * (@tomthewebmaster)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/twitter-feed-regular-expressions/)
 * Hi,
 * I am trying to use regular expressions to add links in the appropriate places(
   regular links, hashtags, @ replies) in a Twitter RSS feed I have on my blog.
 * Currently, I am using the following functions:
 * `$text = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)
   @i', '<a href="$1">$1</a>', $text); /* URLs */`
 * `$text = preg_replace('/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/','$1<a href="http://
   twitter.com/$2">@$2</a>',$text); /* @replies */`
 * `$text = preg_replace('/([^a-zA-Z0-9-_&])#([0-9a-zA-Z_]+)/',"$1<a href="http://
   twitter.com/search?q=%23$2">#$2</a>",$text); /* hashtags */`
 * The functions work so long as there is not a hashtag or @ reply at the beginning
   of the tweet. A link is not applied to hashtags or @ replies in this position.
   For regular links in this position, a link is properly applied.
 * Let me know if you have any questions, and thanks in advance for your assistance!

Viewing 1 replies (of 1 total)

 *  Thread Starter [Tom Lany](https://wordpress.org/support/users/tomthewebmaster/)
 * (@tomthewebmaster)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/twitter-feed-regular-expressions/#post-1619326)
 * I was able to find a great article with expressions that work for this purpose:
   [http://www.snipe.net/2009/09/php-twitter-clickable-links/](http://www.snipe.net/2009/09/php-twitter-clickable-links/)

Viewing 1 replies (of 1 total)

The topic ‘Twitter Feed Regular Expressions’ is closed to new replies.

## Tags

 * [regular expressions](https://wordpress.org/support/topic-tag/regular-expressions/)
 * [RSS](https://wordpress.org/support/topic-tag/rss/)
 * [twitter](https://wordpress.org/support/topic-tag/twitter/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 1 reply
 * 1 participant
 * Last reply from: [Tom Lany](https://wordpress.org/support/users/tomthewebmaster/)
 * Last activity: [15 years, 10 months ago](https://wordpress.org/support/topic/twitter-feed-regular-expressions/#post-1619326)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
