python: convert format string to regular expression,return ''.join(parts)