(Useful) Stupid Regex Tricks?
careysb writes to mention that in the same vein as '*nix tricks' and 'VIM tricks', it would be nice to see one on regular expressions and the programs that use them. What amazingly cool tricks have people discovered with respect to regular expressions in everyday life as a developer or power user?"
(Useful) Stupid * Tricks
Yes sir, that will guarantee a front page story. You better head back to the drawing board if it doesn't fit that pattern. Next week: (Useful) Stupid Starcraft Tricks.
format c:*.*
You see yourself in digg.com. You are likely to be eaten by a grue.
-- Por mais que eu ande no vale das trevas e da morte, meu PowerMac G4 Não Travará!!!
Stupid (Useful) Ask Slashdot tricks?
I'm not sure whether these are legitimate, or just a "I don't know what the hell I'm doing, so let's see if I can get someone else to show me how to do my job, under the guise of sharing information."
I'd like to say the former, but my cynicism is making me lean to the latter.....
"City hall" in German is "Rathaus" Kinda explains a few things......
Why couldn't Bill try out his regular expressions?
His mom wouldn't let him play with matches.
I've never found regexes to be useful at all. I prefer to write my own parsers from scratch in assembly language, or conway's game of life, if I'm feeling m/(ambitious|artistic|autistic|masochistic)/.
But even an artist gets lazy sometimes.
Not only are you showing off with a lower member id than me, do you also have to come up with a cooler regexp than me?
I can easily beat you on the UID, but I couldn't regex the a out of an apple.
Do not meddle in the affairs of sysadmins, for they are subtle, and quick to anger.
Best part of that Regex? It's easy to modify too!
MABASPLOOM!
Not only are you showing off with a lower member id than me
:-D
Low ID = old fart. He may be a regexp wizard, but he probably looks like gandalf too
I wrote my first program at the age of six, and I still can't work out how this website works.
Write a Regex for them! :D
systemd is not an init system. It's a GNU replacement.
ISO Date (19th to 21st century only)
^((18|19|20)\d\d)-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])$
This regexp is ISO certified. The certificate is valid until 2009-02-31.
That also fails beautifully with an address like "2001:db8:3c4d:48:a00:20ff:feb9:4c54", which is perfectly valid.
Unless you know you're going to be dealing with numeric IPv4 addresses in a specific format, it would be best to pass them to getaddrinfo() (with AI_NUMERICHOST if you want to avoid DNS) and let somebody else worry about validating them properly.
#$%^&*(&^%{{}}{/\/\||```
(No, that's not a regex at all. And no, I don't even have a single girlfriend.)
8 of 13 people found this answer helpful. Did you?
That last bit is the perlre for a zero-width negative look-behind assertion
It certainly looks like English, but I have no idea what that means. Whatever it is, it sure seems to help cure insomnia.
Finally had enough. Come see us over at https://soylentnews.org/
holy crap. You DOCUMENTED your regular expression? You shall be thrown into the pit!
Anyone seen my low uid? last seen 10 years ago while panning the #@$# out of Taco's 'web based discussion system'
And as a bonus, it can be used as a source of random bits, after base-64 decoding.
No point, really. You old timers always seem to come out of the woodwork whenever low-UIDs come up in conversation :-)
I, for one, am looking forward to the inevitable
That was a new one on me; I hadn't encountered that award before. Would something like:
<REPORT_NAME sed 's/[^a-z0-9,.-]//gi' > REPORT.out
be preferable in this instance?
It is a solemn thought: dead, the noblest man's meat is inferior to pork.
I came up with a Regex that can be used to match literally anything (yes, anything!). It is, therefore, the most flexible regex ever concocted. Here it is:
.*
Hmmm... until recently I didn't even realize that low ID's were in vogue :)
You think THAT'S cool? I've seen CMDRTACO posting! Now that was a sight to behold. Actually I think I even saw a -1 once, which was his mom.
== Jez ==
Do you miss Firefox? Try Pale Moon.
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
-- Jamie Zawinski
>> Standing on head makes smile of frown, but rest of face also upside down.
You must be new h... (looks at PP's ID, gasps)
Nevermind.
The Hacker's Guide To The Kernel: Don't panic()!
So, would anyone like to buy my new T-shirt, it says "There is no place like 2130706433."
"Alcohol, Tobacco, Firearms, and Explosives" should be a convenience store, not a government agency.
I'd rather take issue with the fact it completely fails on IPv6 addresses.
Wake me up when that actually matters, k?
My blog