Created
April 2, 2012 01:43
-
-
Save cristianrasch/2279955 to your computer and use it in GitHub Desktop.
Python's re#findall
This file contains 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 | |
# returns a list of 2-tuples: [('a', 'b'), ('c', 'd'), ('e', 'f')] | |
re.findall(r'([a-z])\d([a-z])\s', 'a1b c2d e3f ') | |
# returns a list of strings: ['1', '2', '3'] | |
re.findall(r'[a-z](\d)[a-z]\s', 'a1b c2d e3f ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment