Compile python 2-> regular expressions

We run these regular expressions on every line, so just compile them
once.

Change-Id: I93be30f2705f8c2263f64c7d335d1a389884ed7a