Skip to content

Instantly share code, notes, and snippets.

@kwellman
Created May 5, 2012 21:18
Show Gist options
  • Save kwellman/2605638 to your computer and use it in GitHub Desktop.
Save kwellman/2605638 to your computer and use it in GitHub Desktop.
Mining twitter blog post (make_regex.py)
import re
def make_regex(query):
"""Returns a compiled regex. Use returned object like so regex.search(tweet)"""
s = r'(\s\S+){0,2}\s'.join(query.split())
return re.compile(s, re.IGNORECASE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment