Remove repeated re.sub() calls

Briefly tested - please test more
Merge pull request #125 from tomchadwin/master

Remove repeated re.sub() calls