Skip to content

Instantly share code, notes, and snippets.

@StephenFordham
Last active April 8, 2019 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StephenFordham/ddcfef60921c133999699ee4bf1213d3 to your computer and use it in GitHub Desktop.
Save StephenFordham/ddcfef60921c133999699ee4bf1213d3 to your computer and use it in GitHub Desktop.
RegexExample3
import re
DNA = 'GAGCGCTAGCCAAA'
match = re.search('AAA', DNA)
print(match.start())
#11
print(match.end())
#14
print(match.span())
# (11,14)
print(match.group())
# AAA
# if we call the group method on the result of a regex search
# we get the portion of the string that matched the input string
# that matched the pattern
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment