Regex Cheat Sheet: Learn Regular Expressions with 83 Flashcards
Learn regex with 83 flashcards: quantifiers, character classes, lookarounds, backreferences, flags and 25 ready patterns for email, URL, IPv4 and dates.

Studying. But it's also a video game. 🎮
Flashcards, quizzes and games that make you actually remember.
Posted by
Related reading
Master Dynamic Programming with 30 Flashcards: Memoization, Knapsack, LCS and Bitmask DP
Master dynamic programming with deck AI3432: 30 flashcards on memoization, tabulation, knapsack, LCS, LIS, edit distance, Kadane, bitmask and digit DP.
Study Guide: Software Testing in 40 Flashcards — Unit, Integration and 30 More Test Types
Learn software testing with 40 flashcards: unit vs integration, the test pyramid, smoke vs sanity, load vs stress, code coverage, mutation testing and TDD.
Learn Big O Notation in German: 44 Flashcards on Landau-Notation, Schranken and Sorting Costs
German edition of the Big O flashcard deck: obere, untere and scharfe Schranke, Mergesort, Knoten and Kanten, plus three cards to fix before you study.
Regex looks like line noise until you notice it is built from about twenty symbols. The Regex deck (code JA2754, 83 cards) covers all of them, from the dot to lookbehinds, then puts them to work in about 25 real patterns: email, URL, IPv4, dates, passwords, slugs, hashtags.
Study this deck: Regex
1 / 10Regular expression (regex)
Tap the card for the answer · swipe right if you knew it, left if not
The deck comes in two passes
Cards 1-46 are short definitions. Cards 47-83 go back over the same ground with worked examples. Roughly 14 topics show up twice: dot (2 and 47), * (4 and 48), {n} (5 and 53), {n,m} (6 and 54), greedy vs lazy (19-20 and 55), lookarounds (24-27 and 62-63), backreferences (34 and 68), word boundaries (35 and 67), plus the email, URL, phone, IP and hex patterns. When two cards overlap, keep the one with the example. You end up with about 65 cards that each pull their weight.
Sample cards
| Front | Back |
|---|---|
What does \b match? | A word boundary (position between word and non-word character) |
[^abc] | Any character except a, b, or c (negation) |
| Lazy quantifier | Matches as little as possible: *?, +?, {n,m}? |
| Greedy vs non-greedy | <.*> matches the whole <div>text</div>; <.*?> matches <div> |
| Negative lookahead | (?!...), e.g. ^(?!.*word).*$ = lines not containing word |
| Backreference | (\w+)\s+\1 matches repeated words like hello hello |
| Non-capturing group | (?:https?|ftp):// groups without capturing |
| Catastrophic backtracking | (a+)+b on aaaaaaaaaaaa explodes; simplify or use atomic groups |
\A and \Z | Absolute start/end of string, unaffected by multiline mode |
What you'll memorize
Metacharacters . ^ $ \ and the pipe for OR; quantifiers *, +, ?, {n}, {n,}, {n,m}; shorthand classes \d, \w, \s and their opposites, [\s\S]; character classes [a-z], [a-zA-Z0-9], negated [^...]; escapes \., \n, \t, \r; capturing, non-capturing and backreferences \1/$1; positive and negative lookahead and lookbehind; flags i, g, m, s; anchors \A, \Z, \z. Patterns: email, URL, domain extraction, US phone, IPv4 with 0-255 octets, YYYY-MM-DD, 24-hour HH:MM, hex colours, strong passwords, usernames, quoted strings, credit cards, scientific notation, HTML tag stripping, duplicate words, capitalised words, URL slugs.
Two fixes worth making
- Card 65 says "S flag". The dotall flag is lowercase
s(/pattern/s,re.DOTALLin Python). Uppercase\Smeans "non-whitespace", which is a different thing entirely. Edit the front to readsso you don't mix them up. - Flags and anchors depend on the language.
gis JavaScript only (Python usesre.findall). Card 33 is clearer as "m:^and$match at the start and end of each line".\Zbehaves differently in Python and PCRE, and lookbehind support varies too (card 63 says so). Tag each card with JS, Python or PCRE, and test it at regex101.com with the right flavour picked.
How to study it
Put the pattern on the front and say what it matches; the deck mostly goes the other way. Then go through the patterns symbol by symbol. The IPv4 card (59) is a good test: if you can explain 25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?, you know alternation, character classes and optional quantifiers.
Find Regex (JA2754) in the Flip It library. Next in the category: Sorting, Searching & Graph Algorithms. You'll use regex daily in modern JavaScript.
Ready to learn faster? 🚀
Join FLIP IT for free and turn studying into a game.