Rabu, 30 Oktober 2013

My Rendezvous with Regex

I cant say how much I love Regex. Regex and Perl are the love of my life (for now). First time experience is using Perl. I remember correctly that I bought small book, very handy. It has all meta characters in it. I'm not really willing to give it up even though never really use it anymore.
Anyway, it started with golden number. Mobile golden number. Nothing will beat it the most except regex. There are 5000 numbers we have to categorize. I can stop feeling amazed of how my colleague did it. He did it one by one using Excel sheet. I can't imagine working with 5000 rows. I probably will have to wear glasses afterward.
I'm sharing this here for you guys who are in the same pain as my colleague. First step to do this is for you to find the algorithm for vanity level. Maybe in the next 5 years, this algorithm we wont need anymore. Why? I have a dream that eventually people will use VoIP rather than phone numbers. It's damn lot easier to just remember yuvi@skype.com rather than 08551100111.
Matches 5 digit
Matches XX YY XX
Matches XXX d YYY or XXX dd YYY
Matches Xy Xy X at the end
Matches AA BB A at the end
Matches Xy Xy Xy
Matches XXX d YYY
Matches X yyyy X
Matches X yyyy X

And there are a lot more to be honest. And when you're doing this, you have to be very careful. As in access rules, the most specific should be set first, or else, your number will end up having the lowest category.

Tidak ada komentar: