Skip to content

Instantly share code, notes, and snippets.

@gilesc
Created June 22, 2011 14:39
Show Gist options
  • Select an option

  • Save gilesc/1040231 to your computer and use it in GitHub Desktop.

Select an option

Save gilesc/1040231 to your computer and use it in GitHub Desktop.
python regex example
import re
print [g.start() for g in re.finditer("AT", "CAAATATGAGACATAGACATAGACAGATACG")]
#to match any base (really, any character), use a dot:
print [g.start() for g in re.finditer("G.G", "CAAATATGAGACATAGACATAGACAGAGACG")]
#to match a subgroup:
print [g.start() for g in re.finditer("[AT][AT]", "CAAATATGAGACATAGACATAGACAGAGACG")]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment