Multiple choice technology programming languages

the regex /g.d?c*/ doesn't matches

  1. godccc

  2. gddd

  3. goc

  4. gc

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

The regex /g.d?c*/ matches: 'g' literal, any character '.', optional 'd' (?), then zero or more 'c' (). 'godccc' matches (g-o-d-c-c-c). 'goc' matches (g-o-[no d]-c). 'gc' matches (g-[any char]-[no d]-[no c]=empty, c matches zero c's). But 'gddd' has no 'c' at all - after 'gd', the pattern expects zero or more 'c's but finds 'd', so match fails.