Live data from Hacker News

My favorite regex of all time

catonmat.net

1–10 of 117 posts

Re: My favorite regex of all time

#4
It's clever, but it's also completely unreadable for anyone who didn't read this article. Regexes have serious maintainability issues as it is; let's not make it worse by putting clever tricks in them.

Re: My favorite regex of all time

#7
As someone who makes much of his living rehabilitating old perl scripts, please, if you must use such things, use them like this:

[ -~] #match only printable characters

It takes 5 seconds longer and with regexes, just knowing what the damn thing is trying to do is half the battle. When you use a regex, use a comment. Its the civil thing to do.

Re: My favorite regex of all time

#9

As someone who makes much of his living rehabilitating old perl scripts, please, if you must use such things, use them like this: [ -~] #match only printable characters It takes 5 seconds longer and with regexes, just knowing what the damn thing is trying to do is half the battle. When you use a regex, use a comment. Its the civil thing to do.

Yea, anytime I use a regex that isn't immediately obvious I put it in a function called get_. Unfortunately people that write overly complicated and error prone regexes usually don't choose to document them.

Re: My favorite regex of all time

#10

As someone who makes much of his living rehabilitating old perl scripts, please, if you must use such things, use them like this: [ -~] #match only printable characters It takes 5 seconds longer and with regexes, just knowing what the damn thing is trying to do is half the battle. When you use a regex, use a comment. Its the civil thing to do.

Unless you want to seem clever and impresse the PHB.

It is the selfish (but smart) thing to do.

Post reply on HN