Recall & Review
beginner
What is a character class in regular expressions?A character class lets you match any one character from a set of characters. It is written inside square brackets, like <code>[abc]</code>, which matches 'a', 'b', or 'c'.Click to reveal answer
beginner
What does the quantifier
+ mean in a regex?The
+ quantifier means "one or more" of the preceding element. For example, a+ matches 'a', 'aa', 'aaa', and so on.Click to reveal answer
intermediate
Explain the difference between
* and ? quantifiers.* means "zero or more" of the preceding element, so it can match nothing or many. ? means "zero or one", so it matches either nothing or exactly one occurrence.Click to reveal answer
beginner
What does the character class
\d match?\d matches any digit character, which means any number from 0 to 9.Click to reveal answer
beginner
How do you specify a range of characters in a character class?
You use a hyphen
- inside square brackets. For example, [a-z] matches any lowercase letter from 'a' to 'z'.Click to reveal answer
What does the regex
[A-Z]+ match?✗ Incorrect
The character class [A-Z] matches any uppercase letter, and + means one or more times.
Which quantifier matches zero or one occurrence of the previous character?
✗ Incorrect
The ? quantifier matches zero or one occurrence.
What does
\w match in PHP regex?✗ Incorrect
\w matches letters, digits, and underscore characters.
How would you match exactly 3 digits in a row?
✗ Incorrect
The quantifier {3} means exactly 3 occurrences.
What does the regex
[a-zA-Z0-9] match?✗ Incorrect
The character class includes lowercase letters, uppercase letters, and digits.
Describe how character classes and quantifiers work together in regular expressions.
Think about how you pick letters and how many times they repeat.
You got /3 concepts.
Explain the difference between the quantifiers *, +, and ? with examples.
Focus on how many times the character can appear.
You got /4 concepts.