In case it's helpful, here's the code I use in my Twitter election map:

http://maps.google.com/help/maps/elections/#twitter

    function atLinks( str ) {
        return str.replace(
            /(^|\s)@([\w_]+)/g,
            '$1@<a target="_blank" href="http://twitter.com/$2";>$2</a>'
        );
    }

It goes to a tiny bit of extra work to distinguish @twittername references
from [EMAIL PROTECTED] addresses.

This isn't the jQuery part, just the string parsing.

-Mike

> From: Andy Matthews
> 
> A simple regex should take care of that for you. Just search 
> for any occurrence of @<any number of letters of numbers> and 
> wrap the result in an href tag. 

> From: Betty B
> 
> Fairly new to this, I'd like to know if such a thing is possible with
> jQuery:
> 
> I have a social bookmarks-like page where users can post a 
> link and description. I'd like to have some kind of function 
> that would automatically link @USERNAME to that persons 
> Twitter page (http://
> twitter.com/USERNAME) when, or if, they add their @USERNAME 
> to the description field. (div class="description")
> 
> Can this be done with jQuery? Could someone point me in the 
> right direction?

Reply via email to