Skip to content

Instantly share code, notes, and snippets.

@cristianrasch
Created April 2, 2012 01:43
Show Gist options
  • Save cristianrasch/2279955 to your computer and use it in GitHub Desktop.
Save cristianrasch/2279955 to your computer and use it in GitHub Desktop.
Python's re#findall
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