12.18.2009

Regular Expression Dictionary

Today I was trying to come up with a domain name (which, these days, is insanely difficult to do) for a web site I want to create, and I was trying to combine words relating to the site's content and my personal interests to make a short, memorable name. I found myself trying to come up with words that contained part of my name (like nutmeg or megalomania) or parts of other words, and somewhere amidst the process of wracking my brain for words ending in ical or ism or ist, I had a genius idea: dictionary search using regular expressions.

For those of you who are not familiar with regex's, let me just say they are one of my favorite things about computer programming. Crafting the perfect regular expression is a true art form, and it is almost as satisfying as hot tea after an afternoon of sledding through a snowstorm (almost... but not quite). Anyhow, let's say I wanted to find words containing "ical" at the end: I would use the expression ".*ical" - the dot meaning any character, the star meaning any number of characters, and the ical obviously searching for that character combination. If I wanted to match meg, I could simply do a search for "meg" and no matter where in the word that letter combination showed up, the words would show up as matches to the expression. I was using fairly simple expressions for my purposes, but you could do rather complex searches to find very specific words (like words with only one vowel and other such randomness).

See how amazingly helpful this can be? It's like the ultimate rhyming dictionary, but 10,000 times better. Anyhow, luckily someone else thought it was a pretty sweet idea, too, and they put it online. So today I spent the better portion of my day and night on this site searching like a mad woman. I even considered skipping my guitar lesson (for shame!), though in the end I pried myself away from my new favorite online toy and marched my butt to the subway station.

Anyhow, you should give it a whirl. It's pretty fun.

0 Comments:

Post a Comment

<< Home