Flashcards · Regular Expressions · Free
Regular Expressions flashcards, generated for you.
Example Regular Expressions study cards to learn from right now — then generate a full set from your own notes (plus a practice quiz) and export to Quizlet or Anki. Free, no account needed.
Example Regular Expressions flashcards
What does the `.` metacharacter match in regex?
Any single character except a newline (in most regex flavors). To match a literal dot, escape it: `\.`
What is the difference between `*`, `+`, and `?` quantifiers?
`*` matches 0 or more; `+` matches 1 or more; `?` matches 0 or 1 (optional). All are greedy by default.
What does `[abc]` match, and how is it different from `(abc)`?
`[abc]` matches any single character in the set (a, b, or c). `(abc)` matches the literal sequence 'abc' as a group. Brackets are a character class; parentheses are a group/capture.
What is a greedy vs. lazy quantifier? Give an example.
Greedy matches as much as possible; lazy matches as little as possible. Example: on 'aaa', `a+` matches all three (greedy), but `a+?` matches one (lazy). Add `?` after quantifier to make it lazy: `+?`, `*?`, `??`
What do anchors `^` and `$` match?
`^` matches the start of a string (or line in multiline mode). `$` matches the end of a string (or line in multiline mode). They do NOT consume characters.
What is the gotcha with `[a-z]` vs. `[a\-z]`?
`[a-z]` creates a range from 'a' to 'z'. `[a\-z]` matches literal 'a', '-', or 'z' (the hyphen is escaped/literal). Always escape or position hyphens carefully in character classes to avoid unintended ranges.
What does `\b` match, and when does it NOT work as expected?
`\b` matches a word boundary (transition between \w and \W). Gotcha: `\w` = [a-zA-Z0-9_], so `\b` won't match between a letter and an apostrophe in "don't" the way you might expect.
What is the difference between `(abc)` and `(?:abc)`?
`(abc)` is a capturing group—stores the matched text in a numbered backreference. `(?:abc)` is a non-capturing group—matches but doesn't store. Use non-capturing to avoid overhead and confusion with backreferences.
What does `(a|b|c)` match, and why is alternation order sometimes important?
`(a|b|c)` matches a, b, or c (alternation). Order matters because regex engines use first-match wins: `(cat|cats)` on 'cats' matches 'cat' (stops early); `(cats|cat)` matches 'cats'. Longer patterns should come first.
What is a common gotcha with character class negation `[^...]`?
`[^abc]` matches any single character NOT in {a, b, c}—including newlines by default. Gotcha: `[^\n]` is needed to exclude newlines. Also, `[^]` (empty negation) is invalid syntax in most flavors.
Make your own Regular Expressions study set
Flashcards for related topics
Studying Regular Expressions to build with AI? MindloomHQ turns it into real skills — structured courses, agent projects, and certificates.
Explore MindloomHQ →