Matching and indexing sequences of different lengths