The FindURL class (v1.0)
Whilst I was playing around with the Twitter API I was beginning to get wound up by the fact that the XML feed from Twitter only sends out text versions of tweets and not HTML versions. For example, lets say a tweet says “Check out this cool link: http://www.plagro.com”, the xml feed from twitter would send out:
Check out this cool link: http://www.plagro.com"
as oppose to the html version containing the “a” link tag:
Check out this cool link: <a href="http://www.plagro.com">http://www.plagro.com</a>
So after trawling the forums looking for alternative feeds and/or HTML convertors, I came to the conclusion that it would be easier to write a small class that simply finds links within blocks of text and adds in the html tags so it can be displayed as HTML text. The result is the FindURL class.
You can find the FindURL class here and example files here.
Using the FindURL class is very simple. Firstly unzip it into the place where you store all of your actionscript classes and then use the following two lines of AS code whenever it’s needed. Feed it the text you want converting and then receive the String it returns.
//create a new FindURL and send it the text to process
var linkFinder:FindURL = new FindURL(testString);
//return the new processed text
var newString:String = linkFinder.Process();
Finally, please note that I found the Regular Expression used in my FindURL class online. It IS borrowed, it may not be perfect and I can’t offer you any support on it. I will also happily credit the line’s author when I eventually work out who that is – but that particular piece of code has been used seemingly dozens of times by different developers so the author is still ambiguous.
Hope it’s of use to you! Let me know how you get on and if there’s any way you’d like to see it expanded – I’m always open to suggestion.


sandra407 says:
September 9th, 2009 at 4:33 pm
Hi! I was surfing and found your blog post… nice! I love your blog.
Cheers! Sandra. R.
The Hippy says:
September 9th, 2009 at 7:45 pm
Thanks Sandra, glad it’s of use to you! If you have any ideas for any future experiments/classes I’m open to suggestions. Otherwise you can get updates by following my Twitter feed @burnedouthippy. Thanks again