regex-style pattern matching for sequences (list and array)