Skip to content

Instantly share code, notes, and snippets.

@jroo
Created February 22, 2009 19:01
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 jroo/68569 to your computer and use it in GitHub Desktop.
Save jroo/68569 to your computer and use it in GitHub Desktop.
return list of congressional bill numbers extracted from string
# return list of bill numbers extracted from string
import re
def extract_legislation(haystack):
haystack = haystack.upper()
p = re.compile('S\.?\s?CON\.?\s?RES\.?\s?\d{1,5}|H\.?\s?CON\s?RES\.?\s?\d{1,5}|S\.?\s?J\.?\s?RES\.?\s\d{1,5}|H\.?\s?J\.?\s?RES\.?\s\d{1,5}|S\.?\s?RES\.?\s?\d{1,5}|H\.?\s?RES\.?\s?\d{1,5}|H\.?\s?\R\.?\s?\d{1,5}|S\.?\s?\d{1,5}')
needle_list = p.findall(haystack)
return needle_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment