Amazon interview question

A string pattern matching question. Test cases were tough o crack