Make it Python 2.6 compatible

Flags argument was added to re.sub in Python 2.7 only. This equivalent code will make the script run also on Python 2.6 (and maybe earlier version - but I tested this fix only on Python 2.7 and 2.6).