use python 2.6-compatible re.sub and re.split calls