Multiple choice php

Which of the following regular expressions will match the string no.no.no?

  1. no?no?no

  2. no*no*no*

  3. ........

  4. ........

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The regex ........ in PHP string literals (where \ becomes \ in the parsed string) produces the pattern ..\..\.. in regex, which means: two characters (..), a literal dot (\.), two more characters (..), a literal dot (\.), two more characters (..). This matches no.no.no perfectly. Option A's ? means 'zero or one', Option B's * means 'zero or more', and Option D has incorrect escaping.