Can you can that to `'^%s$' % re.escape(parts[0])` instead?