Search for a given subsequence in a list of strings and transform the resulting list as required