Created
April 14, 2020 11:48
-
-
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
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 | |
| 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