You should be using a natural language parser here, but a regex will do for now. `re.compile` gives you no performance improvement if you call it every single time within the function. Make this regex a global so it's only called once.