H12-725_V4.0 · Question #115
If the regular expression is "abc.de", which of the following will not match the regular expression?
The correct answer is C. abcde. In regex, the . (dot) metacharacter matches any single character - it is not a literal period. The pattern abc.de therefore requires exactly one character (any character) between abc and de, making the full match six characters long. abcde (option C) is only five characters…
Question
If the regular expression is "abc.de", which of the following will not match the regular expression?
Options
- Aabcdde
- Babc.de
- Cabcde
- Dabc+de
How the community answered
(45 responses)- A4% (2)
- B9% (4)
- C71% (32)
- D16% (7)
Explanation
In regex, the . (dot) metacharacter matches any single character - it is not a literal period. The pattern abc.de therefore requires exactly one character (any character) between abc and de, making the full match six characters long. abcde (option C) is only five characters: after matching abc, the dot consumes d, leaving only e - which cannot satisfy the remaining de requirement, so it fails to match.
Why the distractors are wrong:
- A (
abcdde) matches because.consumes the firstd, leavingdeto satisfy the tail. - B (
abc.de) matches because the literal.in the string satisfies the regex dot, which accepts any character including a period. - D (
abc+de) matches because+is just another character here - the regex dot happily consumes it.
Memory tip: Think of the regex dot as a "placeholder that demands exactly one character." If the string has zero characters where the dot stands (like C), the match collapses. Also remember: a dot in a regex is almost never a literal dot - to match a real period, you must escape it as \..
Topics
Community Discussion
No community discussion yet for this question.