Thursday, November 02, 2006

I love regex

This blog may be idle but things happen. Funny thing when you're into stuff up to your neck is that you lose the taste for writing.
So this is not really news but really ok for a quick post.
I had to get into regular expressions because I needed a perl service that could open a page and grab a chunk knowing a tag name and id and replace it's innerHtml with some new content. Well perl was built for this kind of stuff so I went ahead without fears. And it delivered flawlessly.
The good thing with learning new stuff is that you never know when it'll come in handy.
Few months later I was shopping for a 2 or 3 rooms apt here in Cluj. Now here we have a printed paper and if you have time to read all the ads you'll do fine. They have a site too and you can perform pretty decent search actions. I didn't even have time for that. So I looked into their new and shiny RSS feeds. Bad thing they have one feed for the entire real estate section so that isn't really useful when you know what you're looking for. So I said to myself that I could grab that big xml page and regex should be able to handle all the tabled html chunk ads piled inside it and look for what I needed: "JonDoe|SomeAgency sell|sells a 2|3 rooms apt|apartment located in Cluj-Napoca". This translates into (Romanian words):

"/Cluj\s*-\s*Napoca/i",
"/(apt|apartament)/i",
"/(2|3)\s*cam/i",
"/(vand|vinde)/i"


LastRss came very handy in speeding up development. Regex Coach is also invaluable for well ... regex stuff.
And as it was RSS to begin with I kept the flavor because I also use and LOVE NetVibes: the Cluj 2/3 rooms apartments RSS Feed (in realtime so you can be the first to call and buy them all [insert evil laugh here]). Add it to your favorite feed reader to gasp it's full power.
Must admit that this would only help the local readers of this blog but if it helps someone then it's not wasted time.

2 Comments:

Anonymous Dragos Ionita said...

And did you find the apartment you were looking?

5:05 PM, November 02, 2006  
Blogger cosmin said...

:)
Yes, but not trough the RSS feed after all. It helped getting the overall picture on the evolution of the prices though.

6:00 PM, November 02, 2006  

Post a Comment

Links to this post:

Create a Link

<< Home