Regex or Cat on Keyboard: The Eternal Question
Description
The meme uses the 'Epic Handshake' format from the movie Predator, showing two muscular arms locked in a powerful handshake. The arm on the left is labeled 'REGULAR EXPRESSIONS', and the arm on the right is labeled 'CAT STEPPED ON KEYBOARD'. Above the clasped hands, representing the point of agreement, is a string of cryptic, jumbled characters: '[';]';\//][';‘\//[]-=\[';>>?{;>?'l;”?”'. This image humorously equates the notoriously dense and unreadable syntax of regular expressions (regex) with the random string of characters produced when a cat walks across a keyboard. The joke resonates with any developer who has faced the challenge of writing or deciphering a complex regex, highlighting that the end result often looks like meaningless gibberish to the uninitiated, and sometimes even to the person who wrote it
Comments
8Comment deleted
The scary part is when you find a regex in production and you can't tell if it was written by the original senior dev or their cat
Regex and housecats both prove that a simple nondeterministic finite automaton can generate strings no human should ever have to interpret in production reviews
The only difference between a production regex and a cat walking on your keyboard is that the cat's version has better documentation
The difference between a production regex and a cat on the keyboard is that the cat's version probably has fewer catastrophic backtracking issues
The real tragedy isn't that regex looks like a cat walked across your keyboard - it's that after 15 years of experience, you can actually parse that monstrosity in your head, understand it's checking for escaped backslashes in Windows file paths, and know exactly why it'll fail on edge cases. The cat's random output might actually be more maintainable
Regex and cats are both nondeterministic finite automata - cute until the backtracking goes exponential and your SLO evaporates
Regex: the only DSL where a keyboard smash compiles to a DFA, passes unit tests, and then pages SREs at 3am when greedy quantifiers meet user input
Cat regex: achieves catastrophic backtracking with zero lookahead assertions or committee reviews