views:

204

answers:

1

using a twitter display widget and need to add links to the hash tags. so i need a pattern replacement, replacing each string that starts with a hash/pound sign and ends in a space with the twitter search link. i am pretty clumsy w/jquery--can someone point me in the right direction -- thanks, anyone!

something taking me:

// FROM:
<ul id="tweets">
     <li>Some nutty tweet. #nutty</li>
     <li>A fruity tweet here. #fruity</li>
</ul>

// TO:
<ul id="tweets">
     <li>Some nutty tweet. <a href="http://twitter.com/search?q=%23nutty"&gt;#nutty&lt;/a&gt;&lt;/li&gt;
     <li>A fruity tweet here. http://twitter.com/search?q=%23fruity"&gt;#fruity&lt;/a&gt;&lt;/li&gt;
</ul>
+8  A: 

Since you are using jQuery, I would recommend the jQuery Tweetify Text from the CSS-Snippets library.

You would then use it like this (given your code):

$("#tweets li").tweetify();

In addition to matching #hashes, it also turns URL's into hyperlinks, and matches @username and links to their profile.

Doug Neiner
thanks! while i can't use that exactly because of some other restrictions, it's a great example for the replacement i need. thanks again!
wagner