Skip to content

Instantly share code, notes, and snippets.

View jroo's full-sized avatar

jroo jroo

View GitHub Profile
@jroo
jroo / extract_legislation.py
Created February 22, 2009 19:01
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