A Simple Two-Step Guide to Writing Regex
Description
A two-panel comic strip by artist @GARABATOKID titled 'HOW TO REGEX'. The comic features a green dinosaur character in a light blue shirt and red tie. In the first panel, captioned 'STEP 1: OPEN YOUR FAVORITE EDITOR', the dinosaur points to a laptop displaying an empty code editor. In the second panel, captioned 'STEP 2: LET YOUR CAT PLAY ON YOUR KEYBOARD', the dinosaur dangles a cat toy over the laptop's keyboard, where a purple cat is now pawing at the keys. The laptop screen now shows a string of characters typical of a regular expression: '/^([A-Z0-9_\.\-'. The humor is a commentary on the notoriously cryptic and seemingly random syntax of regular expressions, suggesting that their complexity makes them look as if they were generated by a cat walking across a keyboard rather than being written by a human
Comments
7Comment deleted
The main difference between writing regex and performing an arcane ritual is that with the ritual, you at least have a vague idea of what demon you're summoning
Remember: a regex you can still understand after lunch clearly isn’t using enough backreferences - time to deploy the cat again
After 20 years of writing regex, I've finally accepted that the cat method produces cleaner patterns than my attempts to remember the difference between positive lookaheads and atomic groups
This perfectly captures why every team has that one senior engineer who wrote a regex three years ago that nobody dares touch - not because it's critical infrastructure, but because understanding it would require archaeological excavation of Stack Overflow posts from 2009. The real tragedy? That cat-generated pattern probably still has fewer edge cases than the 'properly documented' regex you inherited from the previous architect
Regex is the only DSL where keyboard mashing can pass code review - until RE2 saves prod from your cat’s O(2^n) backtracking art
Regex enlightenment: when cat paws yield patterns that outpace your hand-optimized backtracking hell
Regex: the only DSL where my cat can ship an exponential‑time backtracking bomb that still gets LGTM because nobody wants to own it