New free text search facility

After a long bank holiday monday hacking I've put together a new search facility for my blog. The indexing of documents is fairly simplistic (a complete mapping of words to documents is stored in a database), but it does have one cool feature: search results are shown with a few lines of context from the message, with the words you searched for highlighted. Just like Google :-)

While writting this stuff I found myself writing a loop like this, which I thought was disgusting enough that it had to be left in the code:

for (0 .. $#$match) {
   ...
}

I expect I'll have to tweak my regexes later. I've already had to add some specialness to make a search for “C++” work. The boundaries between words are currently detected with this regex:

our $DEFAULT_REGEX = qr/(?:[^+\w]|(?<![+\w])\+)+/;

< Whitelocks and jalapenos | Tasty Vim syntax colouring in my blog >

Miniblog

(nuggets of inanity)

Tuesday Apr 24th 2007, 16:54 »
Just took the annual web design survey that AListApart do. I don't realy consider myself to be a web designer, but I have been doing a lot of HTML and CSS lately.
Monday Apr 23rd 2007, 18:23 »
Strange, there appears to be a bare-knuckle boxing match going on in the field outside my flat. Wish they wouldn't make so much noise about it.
Thursday Mar 1st 2007, 18:47 »
“In its written form, Hebrew has no vowels, making it the ideal language for texting.”
—Said in jest on some Radio 4 programme just now.

Archive: 2007 · 2006 · 2005 · 2004
Feed