I\'m trying to create the following regular expression: return a string between AUG and (UAG or UGA or UAA) from a follow
Unfortunately the re module does not offer support for overlapping matches at the moment, but you can easily break the solution down like so:
'AGCCAUGUAGCUAACUCAGGUUACAUGGGGAUGACCCCGCGACUUGGAUUAGAGUCUCUUUUGGAAUAAGCCUGAAUGAUCCGAGUAGCAUCUCAG'
matches = []
for m in re.finditer('AUG', str):
for n in re.finditer('(UAG)|(UGA)|(UAA)', str[m.start():]):
matches.append(str[m.start()+3:m.start()+n.end()-3]
print matches