Parsing tweets with PHP

Sunday 14th March

A port of Remy Sharp’s excellent ‘ify’ code.

Just a quick post to announce my release of a PHP port of Remy Sharp’s ‘ify’ script, a very simple chunk of code to auto-link the following parts of a tweet:

such that this text:

I wrote an open letter to @taylorswift13 http://stuffandnonsense.co.uk/s/1239 #sn_1239 (RT please)

becomes this:

I wrote an open letter to @taylorswift13 http://stuffandnonsense.co.uk/s/1239 #sn_1239 (RT please)

Remy’s code is nothing more than 3 regular expressions, so is highly portable. There are many other very similar solutions out there, but Remy’s is the best at handling edge-cases that I’ve come across. I’ll endeavour to update this port whenever the original is updated. All feedback is welcome!


Comments

Mon 15 Mar 2010 08:07

Russell Heimlich

Russell Heimlich said:

Awesome stuff! I used to write my own but these look a lot more accomodating.

Mon 15 Mar 2010 10:15

Five Minute Argument

Five Minute Argument said:

Thanks, Russell. All the work is in Remy’s regexps which are much better than anything else I've seen; I might write a detailed analysis of them if I think it’s worth it!

Leave a comment