Regex literals, character classes, quantifiers, anchors, groups, alternation and common flags.
36 cards · basic cards · AI-written, checked twice. Edit anything.
- What does a regex literal represent?
Show answer
A sequence of characters that defines a pattern to search for or match in text.
- What does the dot (.) metacharacter match in regex?
Show answer
Any single character except a newline (in standard mode).
- How do you match a literal period in regex?
Show answer
Escape it with a backslash: \.
- What does the pipe | operator do in regex?
Show answer
It creates alternation, matching any one of the patterns separated by |.
- What is a character class in regex?
Show answer
A set of characters enclosed in square brackets [] that matches any single character in the set.
- What does \d match in regex?
Show answer
Any digit, 0 through 9.
- What does \w match in regex?
Show answer
Any word character: a-z, A-Z, 0-9, and underscore (_).
- What does \s match in regex?
Show answer
Any whitespace character: space, tab, newline, carriage return, or form feed.
- What does [a-z] represent in regex?
Show answer
Any single lowercase letter from a to z.
- What does [^abc] represent in regex?
Show answer
Any single character except a, b, or c (negation of the character class).
- What does the + quantifier mean?
Show answer
Match one or more of the preceding element.
- What does {n} mean as a quantifier?
Show answer
Match exactly n occurrences of the preceding element.
- What does {n,m} mean as a quantifier?
Show answer
Match between n and m occurrences of the preceding element (inclusive).
- How do you make a quantifier non-greedy?
Show answer
Add a ? after the quantifier (e.g., +?, *?, ??, {n,m}?).
- What is the difference between greedy and non-greedy matching?
Show answer
Greedy matches as much as possible; non-greedy matches as little as possible.