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.