Datadog interview question

Implement a pattern matcher function.