Sorry beeing confusing. All lines should be joind so I want to find all "aligned" words that match the regex part (ct(?:a|g)a(?:c|t))(?:.{$len}) and this six times as there are 6 sequeces. Your code does function but it is not what I want. Thank you anyway.