Skip to content
DevMeme
529 of 7590
CS Fundamentals Post #609 · source on Telegram

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

7
Anonymous ★ Top Pick 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
  1. Anonymous ★ Top Pick

    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

  2. Anonymous

    Remember: a regex you can still understand after lunch clearly isn’t using enough backreferences - time to deploy the cat again

  3. Anonymous

    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

  4. Anonymous

    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

  5. Anonymous

    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

  6. Anonymous

    Regex enlightenment: when cat paws yield patterns that outpace your hand-optimized backtracking hell

  7. Anonymous

    Regex: the only DSL where my cat can ship an exponential‑time backtracking bomb that still gets LGTM because nobody wants to own it

Use J and K for navigation