Amazon Interview Question

Coding question related to RegEx expression