Regular Expression Twitter Linker

Tagged with: , , , ,

Regular expression to link twitter users…


Replace this '@(\w+)'
With this '<a href="http://twitter.com/\1">@\1</a>'

3 Responses to “Regular Expression Twitter Linker

  • 1
    Arun Basil Lal
    June 16th, 2009 00:40

    Binny, I didnt understand a word of that 🙁

    I am interested because its related to twitter, can you give some insight for this no-bie.. ?

    Tell me what it is supposed to do, one application of this code..

  • 2
    Binny V A
    June 16th, 2009 01:37

    Say you write a post about twitter meetup – and put in a lot of twitter handles like @binnyva and @arunbasilllal. Then you decide that you need to link the usernames to their twitter profile. Either you could go and edit all the handles manually, or you could do a regular expression replace.

    It basically replaces a specific string pattern with another pattern. I hope I have made it clear for you. And please curse your college for not teaching your useful stuff like this(this topic was covered in BCK5 in my talk).

  • 3
    Arun Basil Lal
    June 16th, 2009 01:43

    My college never teach me anything I need to know, but gave me some awesome friends and a chance to meet a lot of people. Helps in character formation 😀

    Now got a better picture, but it would be ages when I would be using it somewhere. Hey, cant say actually, life changes in no time… 🙂

Leave a Reply