Skip to content

Instantly share code, notes, and snippets.

@jamespaultg
Created April 14, 2020 11:48
Show Gist options
  • Save jamespaultg/88f18fadd71fa091cf4720a36d6ac942 to your computer and use it in GitHub Desktop.
Save jamespaultg/88f18fadd71fa091cf4720a36d6ac942 to your computer and use it in GitHub Desktop.
Match a regular expression in a given string and get back the value and its start and end position
import re
p = re.compile("[a-z]")
for m in p.finditer('a1b2c3d4'):
print(m.start(), m.end(), m.group())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment