Take the 2-minute tour ×

Struggling with RE to search for sequences 'TAA' (triplets of 3 characters) 'TAA' again.

I tried the following:

re.findall('TAA...+?TAA',seq) which of course does not give triplets but does give me sequences

re.findall('TAA([ATGC]{3})+?TAA' , seq) however gives me a list as output

'AGG', 'TCT', 'GTG', 'TGG', 'TGA', 'TAT',

Any ideas? As I of course can check the output from


if length % 3 == 0, but how to do this with RE?

share|improve this question
Is TAA TAA TAA a valid capture (TAA being out of chance also the middle triplet of 3 characters)? –  Eduardo Ivanec Mar 8 '12 at 13:06

1 Answer 1

You want a non-capturing group.


A non-capturing version of regular parentheses. Matches whatever regular expression is inside the parentheses, but the substring matched by the group cannot be retrieved after performing a match or referenced later in the pattern.

Try this:

re.findall('TAA(?:[ATGC]{3})+?TAA' , seq)
share|improve this answer
Happen to have an idea to combine this with TAA TAG TGA as an first or last encounter?? –  Jasper Mar 8 '12 at 13:13
Solution to myself for others to use: re.findall('(?:TAA|TAG|TGA)(?:[ATGC]{3})+?(?:TAA|TAG|TGA)' , seq) –  Jasper Mar 8 '12 at 13:22

Your Answer


