Regex Humor


On this page, I aim to collect all the tidbits of regex humor I manage to muster. Some of these are the fruit of well-known brilliant minds, some of it I've started to produce, and lots of it will, I hope, be contributed by you guys, who as we know are not only geniuses but also fine humorists.

There's a comment form at the bottom so please fire away. The bits that get good feedback will move to the main section of the page, and your work will get proper attribution.

Lower down there's a collection of all of Randall Munroe's xkcd strips that mention regex.[citation needed]

But first things first: what's the meaning of life?


(direct link)

The Meaning of Life

With gratitude and apologies to Douglas Adams (may he rest in peace):

"O Deep Thought computer," he said, "the task we have designed you to perform is this. We want you to tell us...." he paused, "The Answer."
"The Answer?" said Deep Thought. "The Answer to what?"
"Life!" urged Fook.
"The Universe!" said Lunkwill.
"Everything!" they said in chorus.
Deep Thought paused for a moment's reflection.
"Tricky," he said finally.
"But can you do it?"
"Yes," said Deep Thought, "I can do it. But, I'll have to think about it."
"How long?"
"Seven and a half million years," said Deep Thought.

[Seven and a half million years later.... Fook and Lunkwill are long gone, but their ancestors continue what they started]

"Good Morning," said Deep Thought at last.
"Er..good morning, O Deep Thought" said Loonquawl nervously, "do you have...er..."
"An Answer for you?" interrupted Deep Thought majestically. "Yes, I have."
"And you're ready to give it to us?" urged Loonquawl.
"I am."
"Now?"
"Now," said Deep Thought.
"Though I don't think," added Deep Thought, "that you're going to like it."
"Doesn't matter!" said Phouchg. "We must know it! Now!"
"Alright," said Deep Thought. "The Answer to the Great Question..."
"Of Life, the Universe and Everything..." said Deep Thought.
"Is..." said Deep Thought, and paused.
"Yes...!!!...?"
"Okay, here it is, let me print it out for you," said Deep Thought, with infinite majesty and calm.
Slowly, a narrow tape came out of a small slit in Deep Thought's titanium panels. It read:

^(?=(?!(.)\1)([^\DO:105-93+30])(?-1)(?<!\d(?<=(?![5-90-3])\d))).[^\WHY?]$
"But… What does that mean?" asked Loonquawl.
"I don't know," said Deep Thought. "But I can design a more powerful computer that will be able to tell you that."
"It will take time, though", added Deep Thought.

Curious?
1. On the following link, you can see a demo of the Meaning of Life Regex at work.
2. This page fully explains the regex… But I highly recommend you try to figure it out for yourself—it's a great exercise!
3. Authors: Douglas Adams in this book—and for the regex, Rex—7 August 2014
(to share this: direct link)



(direct link)

The Incomplete Two-Problem Quote

    (…what two problems?…)

Odds are ten to one that you've already heard the famous quote about the two regex problems. Sadly, the quote is incomplete. Jeffrey Friedl did a great job tracking down the original author Jamie Zawinski, and on my side I've been trying to find out the lost words from the complete quote. Maybe you can help.

The Original Quote:

Some people, when confronted with a problem, think
“I know, I'll use regular expressions.”
Now they have two problems.

Obviously, something there is missing… What two problems are we talking about?

Here are some attempts to complete the quote. Please send yours.


The Reversed Quote Hypothesis

Some people, when confronted with a problem, think
“I know, I won't use regular expressions.”
Now they have two problems.

Author: Rex, 21 October 2015

The Parrot Hypothesis

Sometimes, when confronted with a problem, you think
“I know, I'll use regular expressions.”
Now you have two problems:
   1. figuring out what to do with the many hours of tedious coding you just saved, and
   2. having to deal with the trolls who give you an earache parrotting some lame quote about having two problems.

Author: Rex, 7 May 2014

The Recursive Hypothesis

Some people, when confronted with a problem, think
“I know, I’ll quote Jamie Zawinski.”
Now they have two problems.

Source: Martin Liebach, March 4 2009
Variation: I think that reads better with “I know, I’ll call Jamie Zawinski.” Now they have two problems.

Will the well-meaning people of this world bring an end to this awful controversy?
People have been discussing the two-problem question quite seriously on Stack Exchange but have failed to reach a consensus. I sincerely hope that with your help, the strict scientific approach on this page will be more fruitful.

And now… A bit of regex entertainment.


(direct link)

What's the control character for "I smoke dope?"

regex bell character

Author: Rex, 8 May 2014. Source: the marvelous Regex Cookbook, 2nd Ed.


(direct link)

Password Validation

.NET password validation
It's also true in Python 3!

Author: Rex, 8 May 2014


(direct link)

Messy Editor

\x5C[^\cH],u(I)D\g{1}0t!
(Untested. Please don't use this in your code.)

Author: Rex, 8 May 2014


(direct link)

Regex Harassment

Boss: (?![0-57-9])\d[^\D0-8]\?
Employee: (slaps boss)

Author: Rex, 20 July 2014


(direct link)

Regex Humor in the Wild

This section presents tidbits of regex humor found here and there.

From Multiple Sources

Q: What did one regex say to the other?
A: .+
This one is too clever for me. I've read the explanation on Stack Overflow, but I still don't get it.

From Morten Just

Q: What regex are you most likely to see at Christmas?
A: [^L]

Q: Why couldn't Chris try out the regular expressions he created until he left home?
A: His mom wouldn't let him play with matches.

Source: mortenjust


(direct link)

xkcd regex

It seems like regex is now an official xkcd theme. It's fortunate that Randall has an on-and-off obsession with regex (if it's fair to call it that), because since you're reading this page, you probably do too.

Randall seems to have a pretty permissive license, but I'll be seeking permission to use his art here. If you like his work, consider supporting him by buying his merch. I bought his first book, xkcd: volume 0 and already look forward to What If?, named after the eponymous column.

xkcd #208: Regular Expressions
This one is my favorite (and probably everyone else's). I prefer it in this abridged form, but the link will take you to the original

xkcd 208 regular expressions


xkcd #1031: Leopard regex

xkcd 1031 regular expressions leopard regex


xkcd #1171: Perl Problems

I'm not crazy about this one, perhaps because Randall seems to be endorsing the original version of the two-problem quote, which as we've seen is sadly incomplete. But I'm probably missing the irony.

xkcd 1171 Perl Problems


xkcd #1313: Regex Golf

xkcd 1313 regular expressions






next
 Regex Books & More



Buy me a coffee

1-6 of 6 Threads
Frank Rod Reid – behind you
November 14, 2019 - 15:23
Subject: Regex

Hello mister Rex Egg,
I hope you are well. I was wondering if you could assist me with my regex query. I am trying to compute the necessary minimum required strength for a copulative inter coalescent stack-based password management experience (a mouthful, I know). I would like it to restrict emoji and only allow alnum characters from 0-16, no more and no less. We would also like no non English language characters as if we use weird characters e.g Abrahamic characters the database sort of breaks (idk why). WOULD like some help with this as have been struggling on stack overflow no one has came up with good response, having studied your site for quite some time (and found it quite helpful - especially the segment on humour. Keeps me going at work, haha! )
I have this to start and don't know where to go, if you could provide me with a bus ticket to the regex mobile that'd be great. Thanks & Best Reggards (See what I did there, rexegg! ), you ARE the best! Franklin
Reply to Frank Rod Reid
Rex
November 14, 2019 - 22:07
Subject: RE: Regex

Hi Frank, Wish I could help but I'm swamped… There's a decent Abrahamic engine available as a Python module (produced by a Jordanian developer IIRC), can't find it right now but since your comment is live on the site, hopefully someone else will be able to jump in. \bS(h)?al(?(1)o|aa)m\b Rex
Astara – california
June 06, 2019 - 21:19
Subject: explanations

Assuming you are not pulling our leg about not understanding these:
1) for /. */ — since the expression matches "any and everything", so "whatever" you can think of. "whatever" is slang today for "some" agreement whether you really agree or not. 2) the 2 problems — by solving it with a regex, you've added another problem — the problem of writing a regex that solves the problem. Doing that is at least as difficult as the original problem. Like I said — assuming you were not pulling out leg!
Mario – Germany
June 23, 2016 - 02:14
Subject: humor proposal

How about this:
What do you ask for if it's not enough? M|e
Steve – Sydney
May 12, 2016 - 09:52
Subject: RE: Now they have two problems.

Some people, when confronted with a problem, think
"I know, I'll use regular expressions. "
Now they have a job.
Peter O – Sweden
October 21, 2015 - 06:00
Subject: Subject: RE: Now they have two problems

Is the request to complete this quote advanced irony?
The quote is complete.
You have problem 1.
And you're using regexes, problem 2.
Perhaps it is too negative about regexes for you to parse.
Reply to Peter O
Rex
October 21, 2015 - 17:53
Subject: RE: Now they have two problems

Hi Peter,
Aha, you mentioned irony. Maybe there is life out there after all.

I've been shocked at the number of people who didn't get the joke and wrote in to explain the so-called problems over the past year. I now regret binning those comments as they would make a fun read, one after the other.

> Perhaps it is too negative about regexes for you to parse.

Nah, I don't think I'm the one with parsing problems.

Kind regards,
R
James
October 17, 2015 - 10:30
Subject: Now they have two problems.

The joke is complete in itself. Using regex restates the original problem, it does not provide a solution. The original problem now exists in two forms, it's original expression and its regular expression form
Reply to James
Rex
October 17, 2015 - 15:37
Subject: RE: Now they have two problems.

Hi James,

Your idea that the regex "does not provide a solution" is highly original. In my experience of thousands of successful data extractions in response to real problems, the regex always seemed to provide a solution—but I must have been deluded. And the extraction strategies almost never felt like restatements—probably another illusion.

Kind regards, Rex


Leave a Comment






All comments are moderated.
Link spammers, this won't work for you.

To prevent automatic spam, may I gently ask that you go through these crazy hoops…
Buy me a coffee