Reputation: 35
i would like to match the sequence (G{x})([ACGT]{1,7})(G{x})([ACGT]{1,7})(G{x})([ACGT]{1,7})(G{x})
where x is a number between 2 and 5, which can vary between matches but must be the same between groups inside a single match. Is it possible to do this with a single regex?
Upvotes: 1
Views: 100
Reputation: 137997
You can use backreferencing:
(G{2,5})([ACGT]{1,7})\1([ACGT]{1,7})\1([ACGT]{1,7})\1
Working example: https://regex101.com/r/yL5tE6/1
Note that it does allow more G
s than there were on the first group, because [ACGT]
might add G
s in adjacent to \1
.
Upvotes: 3