A30-327 · Question #28
Which pattern does the following regular expression recover? (\d{4})[\\]\)-](3)(\d{4})
The correct answer is D. 0000-0000-0000-0000. Option D (0000-0000-0000-0000) is correct because the regex contains \d{4}, which matches exactly 4 consecutive digits - and D is the only choice structured entirely around 4-digit groups, consistent with a credit card number format. Why the distractors fail: A (000-000-0000)…
Question
Options
- A000-000-0000
- Bddd-4-3-dddd-4-3
- C000-00000-000-ABC
- D0000-0000-0000-0000
How the community answered
(65 responses)- A14% (9)
- B5% (3)
- C9% (6)
- D72% (47)
Explanation
Option D (0000-0000-0000-0000) is correct because the regex contains \d{4}, which matches exactly 4 consecutive digits - and D is the only choice structured entirely around 4-digit groups, consistent with a credit card number format.
Why the distractors fail:
- A (
000-000-0000) uses 3-3-4 digit groupings; the leading group has only 3 digits, failing\d{4}which requires exactly 4. - B (
ddd-4-3-dddd-4-3) is a meta-description of a pattern, not a literal string -\donly matches numeric characters, not letters liked. - C (
000-00000-000-ABC) fails on two counts: its digit groups are not consistently 4 digits, and it contains alphabetic characters (ABC) which\dcannot match.
Memory tip: Whenever you see \d{n} in a regex, read it as "exactly n digits in a row." \d{4} → "four-digit block" - picture the four groups on a credit card, and D will always come to mind first.
Topics
Community Discussion
No community discussion yet for this question.