Are people seriously still deliberately using ASCII-reliant code?
For file names, URLs, domain names, etc. it's usually the safe thing to do.
My favorite regex of all time
21–30 of 117 posts
Re: My favorite regex of all time
#22It'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
#23It'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.
What else could this have been besides match the character range from space to tilde?
Re: My favorite regex of all time
#24Earlier quoted context omitted.
or even better # Match only printable ASCII characters.
Thank you for that. You have no idea how annoying it is to port perl scripts from ASCII to EBCDIC when they do that kind of thing.
Re: My favorite regex of all time
#25Re: My favorite regex of all time
#26Re: My favorite regex of all time
#27Re: My favorite regex of all time
#28Earlier 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.
http://searchco.de/?q=%5B+-~%5D+ext%3Apod&cs=on http://symbolhound.com/?q=%5B+-~%5D
Symbolhound gives the answer quite well, and searchco.de has some examples of its use in the results.
Re: My favorite regex of all time
#29As 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.
Google is by far the best "comment"
That one author is the only person who knows what s/he is trying to achieve.
That author taking a few minutes to add some comments will save other people the time to search for answers and the time it takes to grok everything.
Re: My favorite regex of all time
#30/^1?$|^(11+?)\1+$/
Which finds prime numbers. Although, I can't for the life of me think of a reason for using it.
http://stackoverflow.com/questions/3296050/how-does-this-reg...