python regex format middle of string code example Example: find and replace subword in word python regex result = re.sub(r"Pulp Fiction", "Forrest Gump", text)