Match alphanumeric patterns in a stream | Optiver Interview Question