Logic

Logic, language and code

Today, I was doing a bit of hacking on this site's integration with Identica, which is written in PHP. Now, it's possible from this post that I'll reveal myself as either a lazy programmer or an ignorant computer scientist! But I'll continue nevertheless.

The task was this: I have a string, the post, which I want to categorise using Drupal's taxonomy system. In order to do this, I need a string of comma separated tags for each post. For the purposes of this, I'm defining a tag as either a hashtag (e.g. #topic), or a group (e.g. !topic). For example, the post:

I'm watching the #snooker on my computer using !linux.

should yield

snooker,linux

Make sense?

View of the Malvern HillsView of BirminghamThe Glyders from Moel SiabodRemains of a SettlementFreedomThe ViewfinderLog