Fixing Twitter
3 months ago
I've not been using Twitter for very long, and although I would struggle to describe what twitter is supposed to be used for, I have found it to be a very nice community to be in and I have been using it as a sort of social bookmarking application, like delicious, posting links to items I want to remember and share with the community.
This is what a typical tweet would look like; a brief description about the link followed by the link itself. While this looks fine, I believe it breaks the web because the description text should be the link. So instead of "The 50 Most Influential Female Bloggers http://tinyurl.com/5o5lk7" it should be "The 50 Most Influential Female Bloggers".
Currently I parse the twitter feed with a very simple regular expression to convert the text links into an anchor tag.
Input = Regex.Replace(Input, @"(http[^\s]*)", "<a href=\"$1\">$1</a>");
Now I just need to modify this regular expression and code to turn my tweets into properly formed anchor tags.
Match tMatch = Regex.Match(Input, @"http[^\s]*");
if (tMatch.Success) {
Input = Input.Replace(tMatch.Value, String.Empty);
Input = "<a href=\"" + tMatch.Value.Trim() + "\">" + Input.Trim() + "</a>";
}
This now produces a nicer twitter feed on my blog for tweets with links and it also leaves alone tweets without links.
The new style tweets are now shown in the left hand menu of my sites (to the left of this post).
