Module 12

Regular expressions: gentle intro

A powerful pattern-matching tool.

Patterns in text

Regular expressions (regex) are a powerful way to search for patterns in text. They look cryptic at first, but they are extremely useful.

import re
seq = "ATGCGTAATGC"
matches = re.findall("ATG", seq)
print(len(matches))
Your task

Use regex

  • Find all occurrences of ATG in a sequence.