Optimise regular expressions to avoid repeated and unecessary compilation

See this [XBMC Forum post](http://forum.xbmc.org/showthread.php?tid=170921&pid=1664571#pid1664571) for example RE analysis that has led to this pull request.

The patch on this PR eliminates many thousands of unnecessary re.compile() calls, saving several seconds on low powered devices such as the Raspberry Pi. There may be other similar optimisations elsewhere, however this is just targeting the low hanging fruit.