Created
June 22, 2011 14:39
-
-
Save gilesc/1040231 to your computer and use it in GitHub Desktop.
python regex example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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