/regex/is a friend

Regular expression — regexp or regex for short — is actually part of daily work with computer, whether you realize it or not. It’s more common knowledge in programming languages or system administration tasks with Unix/Linux system. However, even technical people sometimes find themselves intimidated by regex at some extent.

I was recently involved in a little discussion about regex in an all-things-discussed typical mailing list of Kampung Gajah aka ID-Gmail. While some members found the regex syntaxes more like garbled text but like the output produced by regex, to me regex is a very helpful and powerful tool, and fun to work with. In short, regex is actually a friend.

But no, I’m not writing to discuss about regex in technical. It just came at the same time that I remembered a nice song from Lenka called Trouble is a Friend. I couldn’t help but reintrepreting the lyric to reflect my thought about regex. So here is my version of the song. Enjoy!

Regex it will find you no matter where you go, oh oh
No matter if you’re fast, no matter if you’re slow, oh oh
The eye of the star or the sight in the plus, oh oh
You’re fine for a while but you start to lose your sleep

It’s there in the docs, it’s there in the texts
It waits in the engine, it’s gotta compile
Regex is a friend, yeah regex is a friend of mine, oh oh!

Regex is a friend but regex is a foe, oh oh
And no matter what I feed it it always seems to grow, oh oh
It parses what I write and it finds what I want oh oh
So don’t forget as you ease on down debug

It’s there in the web, it’s there in database
It waits in your shell, it’s gotta match the string
Regex is a friend, yeah regex is a friend of mine, oh oh

So don’t be alarmed if it takes you by the slash
I won’t let it fails, but I’m a sucker for its power
Regex is a friend, yeah regex is a friend of mine, oh oh!

Oh how I hate the way it makes me code
And how I try to make it clear, I try Oh oh, I try!

It’s there in the mac, it’s there in the windows
It waits in the linux, it’s gotta substitute
Regex is a friend, yeah regex is a friend of mine, oh oh

So don’t be alarmed if it takes you by the dot
I won’t let it slips, but I’m a sucker for its speed
Regex is a friend, yeah regex is a friend of mine, oh oh!
Ooo, oh ooo, ooo ahh

Some final notes:

  • The slashes (“//”) before and after “regex” word in the title signifies the regex construction
  • The “is” after trailing slash is actually a valid syntax in regexes
  • The “star” in the third line refers to asterisk character (“*”)
  • In case someone is looking for it, here is the original lyric of Trouble is a Friend

Tinggalkan Balasan

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Ubah )

Twitter picture

You are commenting using your Twitter account. Log Out / Ubah )

Facebook photo

You are commenting using your Facebook account. Log Out / Ubah )

Connecting to %s

Ikuti

Get every new post delivered to your Inbox.