Live data from Hacker News

My favorite regex of all time

catonmat.net

41–50 of 117 posts

Re: My favorite regex of all time

#41

what a plug - obviously the only real purpose of this was to sell those t-shirts.

I'm sorry that was not the purpose. I just wanted to share this regex trick that I had in my mind. I added the shirts only later when I saw that the article is getting very popular. People really seemed to like my previous tees and it's great to make a little extra money and continue doing what I love - coding and writing blog posts.

Re: My favorite regex of all time

#42

Earlier quoted context omitted.

For file names, URLs, domain names, etc. it's usually the safe thing to do.

Who's filenames aren't unicode? Also domains and URLs can be unicode too.

http://en.wikipedia.org/wiki/IDN_homograph_attack

Re: My favorite regex of all time

#44
I suppose a single regex can be both "favorite" and "worst" at the same time... it's only slightly interesting to know where ~ appears in the ASCII character set, and while someone might recall that space is kinda near the beginning but after the control characters, is it the first helpful printable character? Who knows?

Re: My favorite regex of all time

#45
post #16

Earlier quoted context omitted.

Google is by far the best "comment"

Are you saying people should google regular expressions? in my experience (correct me if I'm wrong) that doesn't work, I've never been able to get google to return relevant results even with quotation marks.

I'm saying that usually comments are either wrong or out of date, developers code one regex, comment it, then fix a bug later and don't, then there's a discrepancy between the comment and the code. It's nearly always easier to just google the code and see what it does, if (as in this case) it's not obvious.

Re: My favorite regex of all time

#48

what a plug - obviously the only real purpose of this was to sell those t-shirts.

I'm sorry that was not the purpose. I just wanted to share this regex trick that I had in my mind. I added the shirts only later when I saw that the article is getting very popular. People really seemed to like my previous tees and it's great to make a little extra money and continue doing what I love - coding and writing blog posts.

well obviously people are interested in it. Can't fault you for trying to make a little scratch

Re: My favorite regex of all time

#49
post #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.

I don't understand why this is "completely unreadable". What else could this have been besides match the character range from space to tilde?

Most people would have to check an ASCII table to know what that range is, though.

Re: My favorite regex of all time

#50
post #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.

I don't understand why this is "completely unreadable". What else could this have been besides match the character range from space to tilde?

The main risk in my mind was that it was some sort of control sequence for a feature I hadn't memorized.

I know there's some syntax I can use to create a zero width negative look behind recursive greedy named capture group back reference. Perhaps hyphen-tilde triggers something like that.

Post reply on HN